Auto refresh cache of redis with MySQL binlog
Fettler
is a service that help you refresh redis cache automatically. By listening on MySQL binlog, you can refresh
redis cache in a timely manner and devoid of sensation or consciousness.
Just install from pypi:
> pip install fettler
The example can be found in config.yml.
First you should run the services, which include producer
, consumer
.
docker-compose
(recommended)
docker-compose up -d --build
Then the services is running.
The producer listens on MySQL binlog and send data changes to redis message queue.
> fettler produce
2021-03-17 23:10:23.228 | INFO | fettler.producer:run:36 - Start producer success, listening on binlog from schemas ['test']....
The consumer consume message queue and delete invalid caches by data changes from binlog and refresh policy registered.
> fettler consume
2021-03-17 23:10:36.953 | INFO | fettler.consumer:run:21 - Start consumer success, waiting for data changes and delete invalid caches...
If you only need one consumer, you can just run the producer and consumer in one command.
> fettler start
2021-03-17 23:10:05.226 | INFO | fettler.consumer:run:21 - Start consumer success, waiting for data changes and delete invalid caches...
2021-03-17 23:10:05.230 | INFO | fettler.producer:run:36 - Start producer success, listening on binlog from schemas ['test']....
See examples to see how to add cache refresh policy in you application.
This project is licensed under the Apache-2.0 License.