1.0.5 • Published 3 years ago
@jsonbourne.xyz/redis v1.0.5
ioredis wrapper with fallback callback function
simple wrapper for ioredis that uses a callback function to fallback to fetch data from slower data source
Installation
Install my-project with npm
npm i @jsonbourne.xyz/redis
Usage
import Redis from '@jsonbourne.xyz/redis'
const redisURL = 'rediss://123456789'
const redis = new Redis(redisURL)
const data = redis.getOrFallback('key', async () => {
// if redis key is empty fall back to slow data aggregation
return slowDatabaseCall()
})
console.log(data)
//flush / delete specific key
redis.flush('key')