The redis proxy is implemented with python flask. There are three major compoents: Proxy, Cache, and RedisFence. Their relationships are illustrated by this chart.
When a request get to the proxy, it first tries to fetch from the cache. If it does not exists in the cache or the cache entry has expired, then it will incur a redis operation to fetch from the backing redis server. Once the record is succesfully fetched from redis, it stores that record to the cache. If the cache reaches the capacity, it removes the least recent used cache entry implemented using double linked link.
This is implemented using a double linked list. get -> O(1) set -> O(1)
All the configuration is in config.py. Once you are happy with the config, you can start the proxy service by running:
make run
This requires valid backing redis server host and port specified in config.py
make test
Assuming the proxy service listens on localhost and port 8000
curl http://127.0.0.1:8000/get?key="test"
Create python flask framework - 1 hour.
Implement LRU cache - 1 hour.
Implement proxy logic - 1 hour.
Implement Redis get with retry - 2 hours.
Unit tests and integration tests - 2 hours.
Bonus Redis Client Protocol - cannot find more time