alien-node-redis-utils
Version:
Helper functions for Redis cache on NodeJS
33 lines (25 loc) • 727 B
JavaScript
;
const constants = require('./_constants');
const _get = (cacheKey, callback) => {
if (cacheKey === constants.FAKE_CACHE_KEY_EXISTS) {
return callback(undefined, constants.FAKE_ITEM);
} else {
return callback(constants.FAKE_ERR, undefined);
}
};
const _del = _get;
const _set = (cacheKey, stringifiedData, exFlag, expTime, callback) => callback(null, cacheKey);
const _keys = (cacheKey, callback) => {
if (cacheKey === constants.FAKE_CACHE_KEY_EXISTS) {
return callback(undefined, [cacheKey]);
} else {
return callback(undefined, []);
}
};
const mockRedisClient = {
'get' : _get,
'del' : _del,
'set' : _set,
'keys' : _keys
};
module.exports = mockRedisClient;