Bastian
This tool is useful for situations where you make many requests for known sets of data, and have partial cache misses.
For example, if you would like to access restaurants 1, 2, 3
, and you already have restaurants 2, 3, 4
in the cache, you should only read restaurant 1
from disk.
npm install --save bastian
Example Collection Usage
var request = ;var redis = ;var Bastian = ; var cache = redis; cache; { const VERSION = 'v4'; cache;} ; ; ; ;
Example Singular Usage
We also expose a method called .get()
which is useful for loading singular items.
Note that the id
parameter is optional.
If present it will be appended to the key in the same manner that lookup()
appends (they're compatible).
If missing it will not be appended and will not be provided to handler()
.
var request = ;var redis = ;var Bastian = ; var cache = redis; cache; { const VERSION = 'v4'; cache;} ; ; ; ;
TODO
- Prevent the same process from making duplicate simultaneous lookups
- Keep a local array of requested entities
- Prevent multiple processes from making duplicate simultaneous lookups
- Keep a list of requested entities in Redis
- Use Pub/Sub to announce when data has become available