Skip to content

Conversation

@SystemKeeper
Copy link
Contributor

@SystemKeeper SystemKeeper commented Nov 14, 2025

I looked really hard, but to me the condition is wrong. There are 2 cases:

  1. If there's no distributed cache, we ensure that the local cache is not set to APCu

OR

  1. If the distributed cache is set, it should not be set to APCu

So having:

  'memcache.local' => '\\OC\\Memcache\\APCu',
  'memcache.distributed' => '\\OC\\Memcache\\Redis',

should be perfectly fine. But from the current code, it is invalid, since $distributedCacheClass === '' is already false and everything is combined with &&.

After changing the code to || I hit the createDistributed line in my local environment correctly.

@bigcat88
Copy link
Contributor

Thanks for finding this!
What do you think about such change:

if (
    ($distributedCacheClass === '' && $localCacheClass !== \OC\Memcache\APCu::class)
    || ($distributedCacheClass !== '' && $distributedCacheClass !== \OC\Memcache\APCu::class)
) {
    $this->cache = $cacheFactory->createDistributed(Application::APP_ID . '/service');
}

For the case when memcache.distributed=`` and memcache.local=`APCu` ?

Signed-off-by: Marcel Müller <marcel-mueller@gmx.de>
@SystemKeeper SystemKeeper force-pushed the fix/noid/cache-condition branch from 49aeab6 to 03cc7a1 Compare November 16, 2025 16:32
@SystemKeeper
Copy link
Contributor Author

What do you think about such change

Yes, makes sense. Otherwise we would end up again with APCu as the cache. I updated the PR accordingly.

@SystemKeeper
Copy link
Contributor Author

SystemKeeper commented Nov 16, 2025

Now I am wondering, would we need to check $localCacheClass !== '' as well, or is it fine for your use-case?

Edit: Seems to be fine from a quick glance. In that case the NullCache is assigned, which would return null on get anyway and we fallback to querying the db.

Copy link
Contributor

@oleksandr-nc oleksandr-nc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yep, with the adjusted condition I guess we are fine

@SystemKeeper SystemKeeper merged commit 4511684 into main Nov 16, 2025
34 checks passed
@SystemKeeper SystemKeeper deleted the fix/noid/cache-condition branch November 16, 2025 18:25
@oleksandr-nc
Copy link
Contributor

/backport to stable32

@oleksandr-nc
Copy link
Contributor

/backport to stable31

@oleksandr-nc
Copy link
Contributor

@SystemKeeper can you please initiate backports? looks like bot ignores me 🤔

@SystemKeeper
Copy link
Contributor Author

It's not you, the bot is down :-(

@SystemKeeper
Copy link
Contributor Author

/backport to stable32

@SystemKeeper
Copy link
Contributor Author

/backport to stable31

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants