Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Missing expire/TTL on Redis keys #131

Open
fredriktid opened this issue Mar 4, 2021 · 4 comments
Open

Missing expire/TTL on Redis keys #131

fredriktid opened this issue Mar 4, 2021 · 4 comments

Comments

@fredriktid
Copy link

When inspecting Redis keys from this bundle they're missing expiration/TTL:

$ redis-cli -n 1
> TTL namespace:tag-content-15681
(integer) -1

To avoid maxing out Redis memory with the "volatile-lru" eviction strategy one can define a "default_lifetime" in app/config/cache_pool/cache.redis.yml .

services:
    cache.redis:
        class: Symfony\Component\Cache\Adapter\TagAware\RedisTagAwareAdapter
        parent: cache.adapter.redis
        tags:
            - name: cache.pool
              clearer: cache.app_clearer
              provider: 'redis://%cache_dsn%?timeout=5&read_timeout=10'
              namespace: '%cache_namespace%'
              default_lifetime: 36000 # 10 hours

volatile-lru states that:

evict keys by trying to remove the less recently used (LRU) keys first, but only among keys that have an expire set, in order to make space for the new data added.

Expected behaviour would be that cache items are given a TTL when defined in Symfony.

Would be great to have some feedback on this. We could possibly provide a PR.

@emodric
Copy link
Member

emodric commented Mar 4, 2021

Hi!

Thanks for the issue and the research!

However, Tags Bundle only reuses configuration from eZ Platform/Ibexa kernel and does not control cache pool at all. So any changes to default config should be done on eZ repos, not here.

I hope this makes sense to you?

@fredriktid
Copy link
Author

fredriktid commented Mar 4, 2021

Thanks for the quick reply. Your description would be the expected behaviour but we're experiencing something else.

redis:6379[1]> TTL namespace:ez-content-info-27475
(integer) 29159
redis:6379[1]> TTL namespace:netgen-tag-2466-0-1
(integer) 29101
redis:6379[1]> TTL namespace:tag-tag-6161
(integer) -1
redis:6379[1]> TTL namespace:tag-content-14291
(integer) -1

It seems to me that eZ-keys (prefixed with ez:) all have a TTL, but some keys from this bundle don't. When I run the following command to list all keys without a TTL, only keys named tag-* are returned.

redis-cli -n 1 keys  "*" | while read LINE ; do TTL=`redis-cli -n 1 ttl "$LINE"`; if [ $TTL -eq  -1 ]; then echo "$LINE"; fi; done;

Though I haven't dived into your code enough to point out any bugs yet.

@emodric
Copy link
Member

emodric commented Mar 4, 2021

It might be that eZ made some modifications to their caching layer since the last time anyone touched the cache layer here in Tags Bundle. That seems to me the most reasonable asumption.

If you have time, it would be appreciated if you can look into it. I will try to find some time too.

@fredriktid
Copy link
Author

Absolutely, I'll try to find some time in the following days.

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

No branches or pull requests

2 participants