Closed benoitdm-oslandia closed 1 year ago
In the case of a deployment with horizontal scalability, the cache will be different from one instance to another. To overcome this problem, we can use a Redis instance which will store the cache!
https://github.com/gorilla/mux/tree/v1.8.0
https://github.com/alrf/go_redis_pg
https://github.com/DenChenn/shorturl-maker
Middleware :
https://www.honeybadger.io/blog/go-web-services/ https://www.honeybadger.io/blog/ruby-to-go-4/ https://dev.to/franciscomendes10866/caching-in-golang-using-redis-418n
Implementation external to the project
[GET] : if the data is not available in the Redis cache, we will look for it in the database we save it in the Redis cache
[GET] : if the data is not available in the Redis cache,
[GET] : if the data is not available either in the Redis cache or in the database, we save the information of non-existence in the Redis cache
[POST] : we always save new data in the Redis cache [PATCH | PUT] : save the data modification in the Redis cache, by overwriting the old cache
[POST] : we always save new data in the Redis cache
[PATCH | PUT] : save the data modification in the Redis cache, by overwriting the old cache
:eye_speech_bubble: Redis stores keys/values
Ex. etag: {...} // réponse json d'une collection
:eye_speech_bubble: where to add the redis instructions?
we will use the available Cacher interface
Cacher
RedisCache
ContainsWeakEtag
AddWeakEtag
RemoveWeakEtag
cf. comment: implementation examples
[ ] Set up a benchmark with/without Redis cache
[ ] Charge test
Implementation internal to the project
[ ] Install K6
https://github.com/grafana/k6
[ ] Write K6 tests
cloned from #77
marked this issue as related to #77
marked this issue as related to #11
Create a cache exploiting redis
In the case of a deployment with horizontal scalability, the cache will be different from one instance to another. To overcome this problem, we can use a Redis instance which will store the cache!
Useful links
https://github.com/gorilla/mux/tree/v1.8.0
https://github.com/alrf/go_redis_pg
https://github.com/DenChenn/shorturl-maker
Middleware :
Steps
Install a Redis server
Update configuration
Set up an implementation logic
:eye_speech_bubble: Redis stores keys/values
:eye_speech_bubble: where to add the redis instructions?
Implement the new
Cacher
interfaceRedisCache
ContainsWeakEtag
AddWeakEtag
RemoveWeakEtag
cf. comment: implementation examples
Add unit test
Benchmark
[ ] Set up a benchmark with/without Redis cache
[ ] Charge test
[ ] Install K6
[ ] Write K6 tests