node cache can return the value directly rather than using a callback
339218
function (key, callback) {
            return client.get(key, function (err, result) {
                return callback(err, result);
            });
        }
736447
function checkCacheResponse(key, err, result, type, cacheIndex){
    if(err){
      log(true, 'Error when getting key ' + key + ' from cache of type ' + type + ':', err);

      if(cacheIndex < self.caches.length - 1){
        return {status:'continue'};
      }
    }
    //THIS ALLOWS false AS A VALID CACHE VALUE, BUT DO I WANT null TO BE VALID AS WELL?
    if(result !== null && typeof result !== 'undefined'){
      log(false, 'Key found:', {key: key, value: result});
      return {status: 'break', result: result};
    }
    var curCache = self.caches[cacheIndex];
    for(var i = cacheIndex + 1; i < self.cachesLength; i++) {
      var nextCache = self.caches[i];
      if(nextCache.checkOnPreviousEmpty || nextCache.expiration > curCache.expiration){
        return {status:'continue', toIndex: i};
      }
    }
    return {status: 'else'};
  }
1136232
def _getCachedValue(obj, relicFunc, resultType):
    
    # If the value has not been previously cached, fetch 
    if not obj.cached:
        obj.cached = resultType()
        relicFunc(byref(obj.cached))
    return obj.cached
519097
function PromiseCache () {
  var cache = this.cache = {};

  this.get = function (key, promiseGenerator) {
    if (key in cache) {
      return cache[key];
    }
    cache[key] = promiseGenerator();
    return cache[key];
  };
}
1160799
function getItem(key, callback) {
        var self = this;

        // Cast the key to a string, as that's all we can set as a key.
        if (typeof key !== 'string') {
            window.console.warn(key +
                                ' used as a key, but it is not a string.');
            key = String(key);
        }

        var promise = new Promise(function(resolve, reject) {
            self.ready().then(function() {
                try {
                    var dbInfo = self._dbInfo;
                    var result = localStorage.getItem(dbInfo.keyPrefix + key);

                    // If a result was found, parse it from the serialized
                    // string into a JS object. If result isn't truthy, the key
                    // is likely undefined and we'll pass it straight to the
                    // callback.
                    if (result) {
                        result = _deserialize(result);
                    }

                    resolve(result);
                } catch (e) {
                    reject(e);
                }
            })["catch"](reject);
        });

        executeCallback(promise, callback);
        return promise;
    }
507783
function(types, callback, scope){
            types = types || [];
            var args = [].slice.call(arguments);

            if($.isString(types)){
                types = types.split(',');
            }
            var len = types.length;
            if(len===0){
                return this;
            }
            args = args.length > 3 ? args.splice(3, args.length-1) : [];
            for(var i = 0;i<len;i++){
                var type = types[i];
                _cache[type] = _cache[type] || [];
                _cache[type].push({callback:callback,scope:scope,args:args});
            }
            return this;
        }
196100
function(namespace) {
            var ncache = {};
            _.each(cache_methods, function(method) {
                ncache[method] = _.partial(Cache[method], namespace);
            })
            return ncache;
        }
928141
function getCache(key, doesDateMatter, callback) {
    key = key.replace(/\//g, '-');
    var cacheFile = __dirname + '/' + CACHE_PREFIX + key + '.cache';
    fs.exists(cacheFile, function (exists) {
        if (exists) {
            fs.stat(cacheFile, function (err, stats) {
                if (err) {
                    throw err;
                }
                if (!doesDateMatter || (stats.mtime.valueOf() > (new Date().valueOf() - 60 * 60 * 1000))) {
                    // The cache is less than 60 minutes old so return the contents
                    fs.readFile(cacheFile, function (err, data) {
                        if (err) {
                            console.error('Error reading the cache file at ' + cacheFile);
                            throw err;
                        }
                        var dataString = data.toString();
                        var dataObj;
                        try {
                            dataObj = JSON.parse(dataString);
                        } catch(e) {
                            dataObj = null;
                        }

                        callback(dataObj, stats.mtime);
                        return;
                    });
                } else {
                    // The cache is older than 60 minutes
                    callback(null);
                    return;
                }
            });
        } else {
            // The cache doesn't exist
            callback(null);
            return;
        }
    });
}
508630
function (fn) { var cache = {}
        return function (value, then) {
            if (value in cache) {                   //  there's a flaw: cache updates after fetch completes, so while fetch is running,
                then (cache[value]) }               //  any subsequent call (until cache is ready) will trigger fetch (as it doesnt know that result is already fetching)
            else {
                fn.call (this, value, function (result) {
                    then (cache[value] = result) }) } } }
262969
function ExecutionCache() {
  var cache = {};

  function getKey(query) {
    return query.queryKey + '(' + JSON.stringify(query.queryParams) + ')'
  }

  function get(query) {
    return cache[getKey(query)]
  }

  this.execute = function (query) {
    var query = _.cloneDeep(query);
    var execution = get(query);
    if (execution) {
      var requestedKeys = _.keys(query.shape);
      if (_.intersection(_.keys(execution.shape), requestedKeys).length != requestedKeys.length) {
        // TODO we probably should also merge the nested shape
        var newShape = _.assign(execution.shape, query.shape);
        query.shape = newShape;
        execution = {
          shape: newShape,
          promise: getHandler(query.name, query.queryKey)(query.shape, query.queryParams, query.type)
        }
      }
    } else {
      execution = {
        shape: query.shape,
        promise: getHandler(query.name, query.queryKey)(query.shape, query.queryParams, query.type)
      };
    }
    cache[getKey(query)] = execution;
    return execution;
  };

  this.get = get;
  this.getKey = getKey;
  return this;
}
317650
function cacheClient (cacheClient) {
    if (defined(cacheClient)) {
        // validate that cache client has required methods
        requireValidCacheClient(cacheClient)
        // set default
        immutable.defaultCacheClient = cacheClient
        // return immutable
        return ImmutableCore
    }
    // return default value
    return immutable.defaultCacheClient
}
123095
function memoize( f ) {
   const cache = {};
   return key => {
      let value = cache[ key ];
      if( value === undefined ) {
         value = f( key );
         cache[ key ] = value;
      }
      return value;
   };
}
1356644
function(callback) {
          if (callback) {
            return body(callback);
          } else {
            return Promise.promisify(body)();
          }
          function body(callback) {
            return self.cacheCollection.remove({
              name: name
            }, callback);
          }
        }
472737
function _getCachedFunction(data, vars, relPath) {
  var func;
  if (app.viewCaching) {
      func = app.views.callbacks[relPath];
      if (func instanceof Function) { return func; }
      else { return null; }
  } else { return null; }
}
747545
function(...args) {
      const cacheKey = keySelector(...args);

      if (isValidCacheKey(cacheKey)) {
        let cacheResponse = cache.get(cacheKey);

        if (cacheResponse === undefined) {
          cacheResponse = selectorCreator(...funcs);
          cache.set(cacheKey, cacheResponse);
        }

        return cacheResponse(...args);
      }
      console.warn(
        `[re-reselect] Invalid cache key "${cacheKey}" has been returned by keySelector function.`
      );
      return undefined;
    }
808353
function(result, cached, callback) {
            self.metacache.store(id, processor, cached, function(err) {
                if (err) return callback(err);
                callback(null, result);
            });
        }
386564
def cached(key, timeout=3600):
    

    def decorator(f):
        @wraps(f)
        def wrapped(*args, **kwargs):
            cache = get_cache()
            # Check if key is a function
            if callable(key):
                cache_key = key(*args, **kwargs)
            else:
                cache_key = key
            # Try to get the value from cache
            cached_val = cache.get(cache_key)
            if cached_val is None:
                # Call the original function and cache the result
                cached_val = f(*args, **kwargs)
                cache.set(cache_key, cached_val, timeout)
            return cached_val

        return wrapped

    return decorator