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