Methods
(static) get(redisClient, key)
Retrieves a serialized class from redis.
Parameters:
Name | Type | Description |
---|---|---|
redisClient |
||
key |
Unique key used to store serialized class in Redis |
Example
const redis = require('redis')
const redisClient = redis.createClient({ host: 'localhost', port: 6379 })
const redisCache = require('./tanagra-protobuf-redis-cache')
const protobuf = require('tanagra-protobuf')
const encoded = await redisCache.get(redisClient, 'foo')
const instance = protobuf.decodeEntity(encoded)
(static) set(redisClient, key, tuple)
Stores a serialized class in redis.
Parameters:
Name | Type | Description |
---|---|---|
redisClient |
||
key |
Unique key used to store serialized class in Redis | |
tuple |
Encoded class and relevant metadata (protobufEncoding, type, schema) |
Example
const redis = require('redis')
const redisClient = redis.createClient({ host: 'localhost', port: 6379 })
const redisCache = require('./tanagra-protobuf-redis-cache')
const protobuf = require('tanagra-protobuf')
const foo = new Foo()
const encodedTuple = protobuf.encodeEntity(foo)
await redisCache.set(redisClient, 'foo', encodedTuple)