Search code examples
google-cloud-platformredisstackdrivergoogle-cloud-monitoringgoogle-cloud-memorystore

GCP flush redis if memory above 90%


Is there a way to flush my GCP Redis when a trigger is triggered?

In my specific case, I'm using the Google StackDriver metrics to monitor and get notified. I want that when my Redis memory is above 90% it will automatically flush. Is there a way to perform this?


Solution

  • Scaling a Basic Tier instance flushes the cache so my suggestion is to configure the instance with a smaller cap (& appropriate eviction policy) then have it scale as needed.

    gcloud redis instances update instance-id --update-redis-config maxmemory-policy=policy

    Alternatively, you can setup a web service to make the appropriate CLI command, but this requires a little more effort.