• Resolved torstensbuechereckede

    (@torstensbuechereckede)


    Hello, thanks for providing the plugin. I have setup Object Cache with Redis and it’s is running. Currently I’m not sure if I do understand the mechanism.

    1. Default TTL is 0, that does mean that keys in Redis Cache never expire or that object caching is running but having no effect? Based on this answer https://wordpress.org/support/topic/wp_redis_maxttl/ I would assume 0 means forever
    2. Assumtion: If TTL is set to e.g. a week which is you standard recommendation for first tests what does that mean? The underlying DB is in my case MYSQL. If there is a select on the DB and TTL is a week the data will be stored for a week in object cache before expiring. If data is changed this is done via Redis object cache before it gets to DB and Redis is tracking the change (if client requires that based on https://redis.io/docs/manual/client-side-caching/) so there is no possiblity of changed data which is missed by the cache? Which means the only disadvantage of high TTL is memory usage and maybe speed if cache is to big? Is that assumption right or wrong?
    3. Default setting is to exclude plugins and themes. Is it a bad idea in general to cache that or is it just for safety reasons because you don’t know how plugins / themes would behave in this context?

Viewing 4 replies - 1 through 4 (of 4 total)
  • Thread Starter torstensbuechereckede

    (@torstensbuechereckede)

    This is maybe also interesting in the context of consitency between redis and sql but I’m not sure if it’s relevant here:

    https://yunpengn.github.io/blog/2019/05/04/consistent-redis-sql/

    Based on this link TTL -1 is forever in redis:

    https://redis.io/commands/ttl/

    Plugin Author Till Krüss

    (@tillkruess)

    Default TTL is 0, that does mean that keys in Redis Cache never expire 

    Correct.

    Default setting is to exclude plugins and themes. Is it a bad idea in general to cache that or is it just for safety reasons because you don’t know how plugins / themes would behave in this context?

    That’s what WordPress does by default. You can try caching the groups, not sure about the side effects.

    Assumtion: If TTL is set to e.g. a week which is you standard recommendation for first tests what does that mean? The underlying DB is in my case MYSQL. If there is a select on the DB and TTL is a week the data will be stored for a week in object cache before expiring.

    The underlying DB doesn’t matter. Redis will discard the key once TTL expires.

    If data is changed this is done via Redis object cache before it gets to DB and Redis is tracking the change (if client requires that based on https://redis.io/docs/manual/client-side-caching/) so there is no possiblity of changed data which is missed by the cache? Which means the only disadvantage of high TTL is memory usage and maybe speed if cache is to big? Is that assumption right or wrong?

    The only way to use Client-Side-Caching is by leveraging Relay.

    Thread Starter torstensbuechereckede

    (@torstensbuechereckede)

    Thanks for your answers.

    Just to understand how dirty cache entries are avoided: I thought this is working on a technical level like database entry is updated and because of that redis is changing the cache entry. Based on other posts which you made in this support forum it seems to be the task of WP to inform the plugin of invalid entries or just flushing in this case. This is very non technical way of decribing it but is this basically right? So e.g. a post is changed and WP flushes the cache for this object or in total?

    Based on memory usage in my case it seems to be that redis cache is flushed several times a day otherwise the memory usage should no go up and down with TTL 0 and way more RAM configured for Redis than it’s used.

    I found your code sniped in the FAQ where this can be analyzed. In which file the add_action has to be placed? I tried default-filters and functions and flushed manually but I do not see log entries. Seems to be the wrong place for the add_action or this is a caching issue.

    Plugin Author Till Krüss

    (@tillkruess)

    If you’re looking for a deeper technical understanding, I’d suggest running redis-cli MONITOR and reading the commands that fire when you update a post.

    If you notice Redis not having many keys, correct, one of your plugins might be flushing the entire cache frequently, which is a bad practise.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Understanding TTL’ is closed to new replies.