openfoodfoundation / openfoodnetwork

Connect suppliers, distributors and consumers to trade local produce.
https://www.openfoodnetwork.org
GNU Affero General Public License v3.0
1.1k stars 710 forks source link

Switch caching backend from Memcached to Redis #7541

Closed Matt-Yorkley closed 2 years ago

Matt-Yorkley commented 3 years ago

Description

We need to make a couple of changes to our caching backend in order to use StimulusReflex.

Why?

Whilst the basic caching features used by the regular Rails cache are essentially the same in Memcached and Redis, Redis provides some higher-level functionality for interacting with Ruby objects in the cache, and StimulusReflex uses some of those advanced features directly.

Also I think traditional session handling doesn't play nicely with Websockets, but this option does :ok_hand:

Requirements

It should be pretty simple, but the plan looks like this (and should be done one step at a time):

  1. Install and configure Redis (ofn-install)
  2. Switch the cache store from Memcached to Redis (main repo)
  3. Switch the session store from ActiveRecord to Redis (main repo)

Parts 1 and 2 should be implemented and tester together. Part 3 can be done afterwards.

Matt-Yorkley commented 3 years ago

Estimates:

I had a quick play with parts 1 and 2 at the weekend, I can drop a couple of PRs in about 20 minutes.

Part 3 might need a bit more finesse, I'd estimate 1-2 hours of dev time and a bit of sysadmin/devops discussion around deployment.

RachL commented 2 years ago

@Matt-Yorkley the main thing left here is ActiveRecord right?

Matt-Yorkley commented 2 years ago

We can probably just close this for now (since most of it is done) and wait and see if we need to switch the session storage from ActiveRecord.