So I have a spring boot application in a microservice architecture, I have made 2 AWS redis clusters X and Y,some services (resides on ec2 instances) are connected to X and other services are connected to Y. Some items in both caches represent the same thing therefore the value of which needs to be synchronized, if I sent the eviction signal for cache X I need to send the same signal for Cache Y. I'm planning to use SNS and SQS as fan out pattern, so every service sends an eviction signal it sends it to a SNS topic then it gets published to SQS queue. Is that possible to evict a redis based on a signal from SQS, and how to write such a signal knowing that in spring boot I use @CacheEvict notation to evict the cache normally .
I managed to do this by sending the key to SQS as a message from my code, and configured a Lambda function to be triggerd by the SQS queue,here is the Lambda code https://github.com/AseelAbushhadeh/Lambda-CacheEvict-SQSListener.git ,you need to give Lambda the right role to access Elasticache and VPC, with the right security group rules.