• Resolved pjv

    (@pjv)


    I have found that every once in a while, admins on a site that I am using this plugin for either cannot sticky a post or cannot unsticky a post unless I manually flush the redis cache (which always immediately fixes it).

    The site goes for long periods of time without any issue, but once the problem arises, it will persist until I flush the cache.

    I went digging into how WP caches the list of sticky pages and it is apparently stored in redis in the options group under the key options:alloptions along with, as the key suggests, all the other options, which makes it a pretty honking huge value.

    Here’s my theory of how this problem is happening: my guess is that the long period between problems is because it only happens when the redis cache gets full or close to full (maxmemory 2GB) and somehow when it comes time to evict old key-value pairs, redis can’t make enough space to store the new options:alloptions data so the old one persists.

    So, just wondering if any other users of this plugin have run into this issue and have found a work-around.

    I may just resort to excluding the options group from redis using the new WP_REDIS_IGNORED_GROUPS define (thanks Till!), but it would be nice to be able to persistently cache that huge blob of data in memory if possible.

Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Author Till Krüss

    (@tillkruess)

    Thanks! Ignoring the options group works for sure. However you could also just trigger a cache flush every time sticky_posts changes, that way you get more out of Redis.

    Also, how big is your options table?

    Thread Starter pjv

    (@pjv)

    options table is 683 rows, 2.1 MB.

    Do you know if WP has a hook for sticky_posts changing?

    Plugin Author Till Krüss

    (@tillkruess)

    Yeah, you could use the post_unstuck and post_stuck actions, or just update_option_sticky_posts action alone.

    add_action( 'update_option_sticky_posts', 'wp_cache_flush' );
    
    • This reply was modified 8 years, 2 months ago by Till Krüss.
    • This reply was modified 8 years, 2 months ago by Till Krüss.
    • This reply was modified 8 years, 2 months ago by Till Krüss.
    • This reply was modified 8 years, 2 months ago by Till Krüss.
    Thread Starter pjv

    (@pjv)

    Thanks Till. Rather than blowing away the whole cache, I did the following which looks like it is working ok:

    function tbp_delete_options_from_cache () {
      wp_cache_delete( 'alloptions', 'options' );
    }
    add_action( 'update_option_sticky_posts', 'tbp_delete_options_from_cache' );
    Plugin Author Till Krüss

    (@tillkruess)

    Nice!

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Sometimes sticky posts won’t unstick w/o cache flush’ is closed to new replies.