Skip to content

Latest commit

 

History

History

stash

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 

Toa Stash

Shared cache and distributed lock manager on top of ioredis and redlock.

Shared cache

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.

Storing objects

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.

Distributed lock manager

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'))
}

Manifest

To enable extension for a component, add null definition to its manifest:

stash: ~

Deployment

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