Redis Proxy is a service which proxies GET requests to a backing Redis instance but returns the value of a specified key from the proxy's local cache if the local cache contains a value for that key.
Modern Linux distro or Mac OS installation with the following software installed:
make
docker
docker-compose
docker build . -t redis-proxy
docker-compose up -d
make test
This will build and launch a test runner container which connects to both the proxy and the backing redis in order to execute automated system tests.
The web server is built with Express and contains two primary components:
- Local Cache: implemented with lru-cache which stores key-value pairs for fast retrieval. Global expiry, fixed key size, and LRU eviction come standard.
- Redis Client: a wrapper around node-redis used for querying the backing redis instance
GET /
serves a static how-to pageGET /api/v1/values/some-key
returns the value for the given key as well as a custom response header calledContent-Source
which indicates from where the value is being returned
- Cache hits are O(1)
- Cache misses are O(1 + r) where r is the Redis access time complexity O(1+n/k) where n is the number of items and k the number of buckets
.
├── .eslintrc.yml // linting rules
├── Dockerfile // builds the redis-proxy image
├── LICENSE // MIT
├── Makefile // single-click build and test
├── README.md
├── docker-compose.yml // defines config for proxy and redis
├── index.html // static page with brief how-to
├── lib
│ ├── cache.js // LRU cache
│ └── redis-client.js // Redis client
├── package-lock.json // describes the exact module tree that was generated
├── package.json // lists the dependencies and project info
├── server.js // proxy entrypoint and main logic. routes are defined here
├── test
│ └── test.js // automated tests with mocha
└── test.Dockerfile // builds the redis-proxy-tests image