1.3.0 • Published 2 years ago

underflag-redis v1.3.0

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

Redis Provider

This is a Redis provider for underflag (feature flag/feature toggle)

Install

Using npm:

npm install underflag underflag-redis

Using yarn:

yarn add underflag underflag-redis

How to use

Example using data from json, but you can get data from anywhere.

import { Underflag, JsonDataProvider } from "underflag";
import { RedisCacheProvider } from "underflag-redis";

const dataProvider = new JsonDataProvider({ 
    data: { feature: true }}
);
const cacheProvider = new RedisCacheProvider();
const underflag = new Underflag({ dataProvider, cacheProvider });
if (await underflag.isOn("feature")) {
    // ...
}

Prefix keys

Add a prefix to all keys, frequently used to group keys or isolate environment, a good example is when have only one database to multiple environment.

// ...
const cacheProvider = new RedisCacheProvider({
    prefix: 'staging:', // can be process.env.NODE_ENV + ':'
    lifetime: 300, // limit cache to 5min
});
// ...
/**
    Find feature staging:feature on redis
    if not found, find key feature on data and set staging:feature on redis to return later
*/
await underflag.isOn("feature"); 

Know more on underflag npm page

License

MIT

1.3.0

2 years ago

1.2.0

2 years ago

1.1.0

2 years ago

1.0.3

2 years ago

1.0.2

2 years ago

1.0.1

2 years ago

1.0.0

2 years ago