INNER CODE UNIT · JavaScript
RedisCache
thinkjs/thinkjs · packages/think-cache-redis/index.js:14
class RedisCache {
constructor(config = {}) {
config = helper.extend({}, defaultOptions, config);
this.redis = new Redis(config);
this.timeout = config.timeout;
}
/**
* get cache content by the cache key
* @param {String} key [description]
* @return {Promise} [description]
*/
get(key) {
return this.redis.get(key).then((data) => {
if (data === null) return undefined; // think-cache-file return undefined
try {
return JSON.parse(data);
} catch (e) {