Abstract function to create cache store
@param [options]
@constructor
341144
function CacheStore(options) {
    if (!options.id) {
        throw new IdNotDefinedError();
    }
    var storeType, _cache;

    function parseKey(key) {
        return key.replace(/[^a-z0-9]/gi, '_').replace(/^-+/, '').replace(/-+$/, '').toLowerCase();
    }

    /**
     * Returns Cache Store object
     * @returns {Object}
     */
    this.getCacheStore = function () {
        return _cache;
    };

    /**
     * Method initiates cache store depends on type
     * @param type {String} cache store type
     * @returns {CacheStore}
     */
    this._setStoreType = function (type) {
        storeType = type;
        var ttl = options.expires || DEFAULT_EXPIRATION_TIME;
        options.max = options.max || 0; //makes lru cache to store infinite no of items
        switch (type) {
            case STORE_TYPE_MEMORY:
                _cache = CacheManager.caching({store: STORE_TYPE_MEMORY, max: options.max, ttl: ttl});
                break;

            case STORE_TYPE_REDIS:
                _cache = CacheManager.caching({store: RedisStore, db: options.db, ttl: ttl, host: options.host,
                    port: options.port, id: options.id
                });
                break;

            default :
                throw new InvalidCacheStoreTypeError(type);

        }
        //exposing delete method alias of _del
        _cache.delete = _cache.del;
        return this;
    };

    //setting public functions
    /**
     * Gets cache item
     * @param key {String} Key to retrieve cache item
     * @param next {Function} callback. parameters are err, value
     */
    this.get = function (key, next) {
        _cache.get(parseKey(key), next);
    };

    /**
     * Sets cache item in cache.
     * @param key {String} Key to retrieve cache item
     * @param value {String} Value to save cache item
     * @param next {Function} callback. parameters are err
     */
    this.set = function (key, value, next) {
        _cache.set(parseKey(key), value, next);
    };

    /**
     * Delete from cache
     * @param key {String} Key to retrieve cache item
     * @param next {Function} callback. parameters are err
     */
    this.delete = function (key, next) {
        _cache.del(parseKey(key), next);
    };

    /**
     * Wraps a function in cache, the first time the function is run,
     * its results are stored in cache so subsequent calls retrieve from cache
     * instead of calling the function.
     *
     * @example
     *
     *      var key = 'user_' + user_id;
     *      cache.wrap(key, function(cb) {
     *          User.get(user_id, cb);
     *      }, function(err, user) {
     *         console.log(user);
     *      });
     *
     * @param key {String} Key to retrieve cache item
     * @param wrapFn
     * @param next {Function} callback. parameters are err, value
     */
    this.wrap = function (key, wrapFn, next) {
        _cache.wrap(parseKey(key), wrapFn, next);
    };

    /**
     * Flushes the current cache store
     * @param next {Function} callback. parameters are err, success
     */
    this.reset = function (next) {
        _cache.reset(next);
    };

    /**
     * Gets all keys associated with this cache store
     * @param next {Function} callback. parameters are err, keys
     */
    this.keys = function (next) {
        _cache.keys(next);
    };
}
1205507
def load(key, options = {})
      if options[:sync] || (value = @cache.load(key, options)) == nil
        value = @adapter.load(key, options)
        @cache.store(key, value, options) if value != nil
      end
      value
    end
794707
function _initStorage(options) {
        var self = this;
        var dbInfo = {};
        if (options) {
            for (var i in options) {
                dbInfo[i] = options[i];
            }
        }

        dbInfo.keyPrefix = dbInfo.name + '/';

        self._dbInfo = dbInfo;
        return Promise.resolve();
    }
1152884
function createCache(array) {
    var index = -1,
        length = array.length;

    var cache = getObject();
    cache['false'] = cache['null'] = cache['true'] = cache['undefined'] = false;

    var result = getObject();
    result.array = array;
    result.cache = cache;
    result.push = cachePush;

    while (++index < length) {
      result.push(array[index]);
    }
    return cache.object === false
      ? (releaseObject(result), null)
      : result;
  }
345584
def store(key, value, options = {})
      @cache.store(key, value, options)
      @adapter.store(key, value, options)
    end
1065762
function(options){
      var storage;

      var StorageType = options.storageType || this.storageType;
      if (_.isFunction(StorageType)){
        storage = new StorageType();
      } else {
        storage = StorageType;
      }

      this.storage = storage;
    }
946234
function resolve(opt) {
	if (opt instanceof Cachers.Base) {
		return opt;
	} else if (opt === true) {
		return new Cachers.Memory();
	} else if (_.isString(opt)) {
		let CacherClass = getByName(opt);
		if (CacherClass)
			return new CacherClass();

		if (opt.startsWith("redis://"))
			CacherClass = Cachers.Redis;

		if (CacherClass)
			return new CacherClass(opt);
		else
			throw new BrokerOptionsError(`Invalid cacher type '${opt}'.`, { type: opt });

	} else if (_.isObject(opt)) {
		let CacherClass = getByName(opt.type || "Memory");
		if (CacherClass)
			return new CacherClass(opt.options);
		else
			throw new BrokerOptionsError(`Invalid cacher type '${opt.type}'.`, { type: opt.type });
	}

	return null;
}
284357
function Filecache(options) {
  options = options || {};

  this.directory = options.directory || path.join(__dirname, '/.cache');
  this.fresh = +options.fresh || 500000;
}
768668
function(options){
        this.type = options.type || EJS.type;
		this.cache = options.cache != null ? options.cache : EJS.cache;
		this.text = options.text || null;
		this.name =  options.name || null;
		this.ext = options.ext || EJS.ext;
		this.extMatch = new RegExp(this.ext.replace(/\./, '\.'));
	}
1064721
function Snippets(options) {
  this.options = options || {};
  this.store = store(this.options);

  this.snippets = {};
  this.presets = {};
  this.cache = {};
  this.cache.data = {};

  var FetchFiles = lazy.FetchFiles();
  this.downloader = new FetchFiles(this.options);
  this.presets = this.downloader.presets;

  if (typeof this.options.templates === 'object') {
    this.visit('set', this.options.templates);
  }
}
1106335
def createStore(self, debug, journalMode=None):
        
        if self.storepath is None:
            self.store._memorySubstores.append(self) # don't fall out of cache
            if self.store.filesdir is None:
                filesdir = None
            else:
                filesdir = (self.store.filesdir.child("_substore_files")
                                               .child(str(self.storeID))
                                               .path)
            return Store(parent=self.store,
                         filesdir=filesdir,
                         idInParent=self.storeID,
                         debug=debug,
                         journalMode=journalMode)
        else:
            return Store(self.storepath.path,
                         parent=self.store,
                         idInParent=self.storeID,
                         debug=debug,
                         journalMode=journalMode)
1070167
def record_store(store)
      store = RecordCache::Base.stores[store] || ActiveSupport::Cache.lookup_store(store) if store.is_a?(Symbol)
      store ||= Rails.cache if defined?(::Rails)
      store ||= ActiveSupport::Cache.lookup_store(:memory_store)
      RecordCache::MultiRead.test(store)
    end
374225
function JugglingStore(schema, options) {
		options = options || {};
		Store.call(this, options);
		this.maxAge = options.maxAge || defaults.maxAge;
		var coll = this.collection = schema.define('Session', {
			sid: {
				type: String,
				index: true
			},
			expires: {
				type: Date,
				index: true
			},
			session: schema.constructor.JSON
		}, {
			table: options.table || defaults.table
		});

		coll.validatesUniquenessOf('sid');

		// destroy all expired sessions after each create/update
		coll.afterSave = function(next) {
			coll.iterate({where: {
				expires: {lte: new Date()}
			}}, function(obj, nexti, i) {
				obj.destroy(nexti);
			}, next);
		};
	}
993425
function QuestionsStore(options) {
  debug('initializing from <%s>', __filename);
  Cache.call(this, options);
  this.createStores(this, this.options);
  this.listen(this);
}
730599
function(options) {
	if (!options) { options = {}; }

	Object.keys(options).forEach(function(k) {
		console.assert(supportedOptions.has(k), 'Invalid cacheKey option: ' + k);
	});

	// default: not an include context
	if (options.isInclude === undefined) {
		options.isInclude = false;
	}

	// default: wrap templates
	if (options.expandTemplates === undefined) {
		options.expandTemplates = true;
	}

	return options;
}
927746
function cacheGet(key, options) {
    if (shouldCache(options)) {
      return;
    }

    if (self.options.cache === 'memory') {
      return self.cache[key];
    }

    return self.options.cache.get(key);
  }
1221598
function MemcacheStore (options) {
  options = options || {};
  this._host = options.host || '127.0.0.1';
  this._port = options.port || 11211;
  this._prefix = options.prefix || '';
  this._user = options.user || '';
  this._password = options.password || '';
  this._pool = options.pool = (options.pool > 1 ? options.pool : 1);
  this._connectionString = this._user + ':' + this._password + '@' + this._host + ':' + this._port;

  debug('create: host=%s, port=%s, prefix=%s, user=%s, password=%s', this._host, this._port, this._prefix, this._user, this._password);

  this._clients = [];
  this._clientIndex = -1;
  for (var i = 0; i < options.pool; i++) {
    this._clients.push(memjs.Client.create(this._connectionString));
  }

  return this;
}