trellis v1.26.1 released

trellis v1.26.1 released

What’s Changed

Full Changelog: https://github.com/roots/trellis/compare/v1.26.0...v1.26.1

wp cache flush seems to clear my entire Redis database, including things added by using the Redis Facade.

Is this intentional? If so, is it avoidable? Or am I just using it all wrong? :thinking:

The use case is that we store all “nice to have, but not life critical” things in Redis so as to not boggle down MariaDB with “11 people clicked an ad in a 7 year old article”.

Which Redis WordPress plugin are you using?

The recommended one:

Have you setup any flush groups? There should be a way to avoid this :thinking:

Never even heard of that before, so nope :smiley:

Edit: I’ve managed to figure out a way of cleaning the object cache without flushing literally everything, feel free looking at it and see if you like it!

 - name: Flush cache for Redis
    command: >
      redis-cli --scan --pattern '*' |
      grep -E '^{{ (vault_wordpress_sites[item.key].db_user | default(item.key | underscore)) }}_wp:|^wp:' |
      tr '\n' '\0' | xargs -0 -r -n 100 redis-cli unlink
    when: item.value.object_cache.enabled | default(false) and item.value.object_cache.provider | default('') == 'redis'
    loop: "{{ wordpress_sites | dict2items }}"
    loop_control:
      label: "{{ item.key }}"
    args:
      chdir: "{{ deploy_helper.current_path }}"

  - name: Flush cache for non-Redis
    command: wp cache flush
    args:
      chdir: "{{ deploy_helper.current_path }}"
    when: not (item.value.object_cache.enabled | default(false) and item.value.object_cache.provider | default('') == 'redis')
    loop: "{{ wordpress_sites | dict2items }}"
    loop_control:
      label: "{{ item.key }}"

Redis Object Cache seems to put everything under “wp” or “db_user_wp” as far as prefixing goes so the above example should work for both us Redis users and non-Redis users.

Maybe I should create a new thread for discussing this issue?

Nice one! :tada:

Would you mind submitting a PR for the Trellis docs for Redis?

Can do!

Just to confirm. Are you thinking that we stick to the default “wp cache flush” as listed in finalize-after.yml and then we prompt people to change it to my commands above if they use the Redis Facade in the Trellis docs for Redis?

If so, that works for me! I can do it tomorrow, no problem.

Actually would this make more sense as a PR? Forgive me, I’m not fully awake or caffeinated yet

I’m perpetually in a “not fully awake yet” state so I hear you! Nothing that coffee or Red Bull can’t fix though. If only there was a Red Bull that could solve the constant talking around me at the office, that would be something.

I think a PR makes the most sense. If it works properly for both Redis and “normal” users then what’s the harm in adding it for everyone, right?

1 Like

Let’s do a PR, thank you!