redis-keyshape
Easily, consistently, clearly access redis keys. Works with node-redis
.
Installation
npm install redis-keyshape
API
addKeyshape(db, keyPattern)
TODO
Example
Problem
- keyname repeated across application
- Temporary variables for key access
var db = ; var key1 = 'foo:' + foo_id;db; var key2 = 'foo:' + foo_id + ':bar:' + bar_id;db;
Solution
var db = ;var redisKeyshape = // Augment the db with keyshapes if the key pattern follows convention*.// * https://github.com/jasonkuhrt/redis-keyshape/issues/7; // auto-exposes as db.foo; // auto-exposes as db.foo_bar // Keyshapes take the same signature except that the key argument// need only include the keyshape's variable.dbfoo // Often keyshapes require multiple variables. In such cases use an array// to provide the keyshape variables.dbfoo_member
License
BSD-2-Clause