Shared cache and distributed lock manager on top of ioredis and redlock.
stash
aspect exposes ioredis
methods.
async function computation (input, context) {
await context.stash.set('key', 'value')
await context.stash.get('key')
}
Keys are component-scoped, meaning that the underlying Redis keys are namespace:name:key
.
async store (key: string, value: object, ...args: Array<string | number>)
async fetch (key: string): object
...args
are the arguments of set
starting from third.
Values are encoded using msgpack.
async lock<T>(id: string | string[], routine: async? () => T): T
Executes routine
once a lock is successfully acquired. Lock ID is component-scoped.
async function computation (input, context) {
await context.stash.lock('lock id', () => console.log('Lock acquired'))
}
To enable extension for a component, add null
definition to its manifest:
stash: ~
stash
context annotation is a Pointer with ID stash
.
stash: # shortcut is available
.: redis://redis.example.com
dummies.dummy: redis://dummies.redis.example.com
Neither password authentication nor TLS are implemented. #367