Hello guys
So, I’m implementing a custom cache store for the nodejs SDK using Redis following this https://github.com/okta/okta-sdk-nodejs#custom-storage
Here the implementation:
import {promisify} from 'util';
const ns = 'my-namespace-user-redis';
export default class RedisCacheStore {
/**
* @param {!RedisClient} redisClient
* @param {!number} keyLimit
*/
constructor(redisClient, keyLimit) {
this._store = redisClient;
this._keyLimit = keyLimit || 100000;
}
/**
* @param {!string} stringKey
* @return {Object}
*/
async get(stringKey) {
const getAsync = promisify(this._store.get).bind(this._store);
const nskey = `${ns}:${stringKey}`;
// console.log('retrieveing the key ', nskey);
const data = await getAsync(nskey);
// console.log('data from redis', data);
return data;
}
/**
* @param {!string} stringKey
* @param {!string} stringValue
* @return {Object}
*/
async set(stringKey, stringValue) {
if (!stringKey) {
throw new Error('Key is required');
}
const nskey = `${ns}:${stringKey}`;
return this._store.set(nskey, stringValue, 'EX', this._keyLimit);
}
/**
* @param {!string} stringKey
* @return {Object}
*/
async delete(stringKey) {
return this._store.delete(stringKey);
}
}
But the get method is always receiving the “key” as “undefined”, so, am I doing something wrong?
Thanks