ehcache不支持putIfAbsent原子操作
496498
@Override
	public synchronized Object putIfAbsent(Object key, Object value) {		
		Cache cache = manager.getCache(ehcacheConf.getPredefinedCacheName());
		if (!cache.isKeyInCache(key)){
			Element element = new Element(key, value);
			cache.put(element);
		}
		Element e = (Element)cache.get(key);
		return e.getObjectValue();

	}
1178902
public void putUnknownHost(String hostname, int netId, String detailMessage) {
        cache.put(new AddressCacheKey(hostname, netId), new AddressCacheEntry(detailMessage));
    }
260165
def clearCache(self):
        ''
        for attr in self.cacheItems:
            if hasattr(self, attr):
                delattr(self, attr)
785367
protected void putToCache(String cacheName, String key, Object value,
            long expireAfterWriteSeconds, long expireAfterAccessSeconds) {
        try {
            ICache cache = getCache(cacheName);
            if (value != null && cache != null) {
                cache.set(key, value, expireAfterWriteSeconds, expireAfterAccessSeconds);
            }
        } catch (CacheException e) {
            LOGGER.warn(e.getMessage(), e);
        }
    }
713433
function(key, fn) {
    var self = this;
    var filepath = this._makeFilepath(key);

    fs.exists(filepath, function(exists) {
      if (!exists) {
        return fn();
      }

      fs.readFile(filepath, 'UTF8', function(err, data) {
        if (err) {
          return fn(err);
        }

        var cache = JSON.parse(data);

        if (!self._cacheIsValid(cache)) {
          return self.del(key, fn);
        }
        fn(null, cache.data);
      });

    });
  }
809099
public function forgetCache()
    {
        foreach (['url', 'js_url'] as $attribute) {
            $key = $attribute.'_'.$this->location;
            Cache::forget($key);
        }
    }
240794
function getCacheKey()
{
  // use the one from the context
  var directories = this.directories || this.defaults.directories;

  return resolveDir(directories)
    + ':'
    + getFiles.call(this, process.env).join(',')
    + ':'
    + resolveExts.call(this).join(',')
    ;
}
364677
function readcache($filename, &$err, $secs2cache, $rsClass)
		{
			$false = false;
			if (!$this->_connected) $this->connect($err);
			if (!$this->_memcache) return $false;

			$rs = $this->_memcache->get($filename);
			if (!$rs) {
				$err = 'Item with such key doesn\'t exists on the memcached server.';
				return $false;
			}

			// hack, should actually use _csv2rs
			$rs = explode("\n", $rs);
            unset($rs[0]);
            $rs = join("\n", $rs);
 			$rs = unserialize($rs);
			if (! is_object($rs)) {
				$err = 'Unable to unserialize $rs';
				return $false;
			}
			if ($rs->timeCreated == 0) return $rs; // apparently have been reports that timeCreated was set to 0 somewhere

			$tdiff = intval($rs->timeCreated+$secs2cache - time());
			if ($tdiff <= 2) {
				switch($tdiff) {
					case 2:
						if ((rand() & 15) == 0) {
							$err = "Timeout 2";
							return $false;
						}
						break;
					case 1:
						if ((rand() & 3) == 0) {
							$err = "Timeout 1";
							return $false;
						}
						break;
					default:
						$err = "Timeout 0";
						return $false;
				}
			}
			return $rs;
		}
838777
private void rethrowOrSwallowIfBackup(CacheNotExistsException e) throws Exception {
        if (this instanceof BackupOperation) {
            getLogger().finest("Error while getting a cache", e);
        } else {
            throw ExceptionUtil.rethrow(e, Exception.class);
        }
    }
539803
function wrapRemoteCache(remoteCache) {
    return {
        get: function (key) {
            var deferred = Q.defer();

            remoteCache.get(key, function (err, value) {
                if (err) {
                    console.log('redis remoteCache.get err ' + err);
                    deferred.resolve();
                }

                if (_.isString(value) && value.charAt(0) === '{') {
                    value = JSON.parse(value);
                }

                deferred.resolve(value);
            });

            return deferred.promise;
        },
        set: function (key, value) {
            value = _.isObject(value) ? JSON.stringify(value) : value;
            remoteCache.set(key, value);
            remoteCache.expire(key, 3600);
        },
        del: function (key) {
            remoteCache.del(key);
        },
        quit: function () {
            remoteCache.quit();
        },
        flush: function () {
            remoteCache.flushdb();
        }
    };
}
1358777
protected void putToCache(String cacheName, String key, Object value, long ttlSeconds) {
        if (cacheItemsExpireAfterWrite) {
            putToCache(cacheName, key, value, ttlSeconds, 0);
        } else {
            putToCache(cacheName, key, value, 0, ttlSeconds);
        }
    }
895350
function(oRequest, oResponse) {
    var aCache = this._aCache;
    if(!aCache) {
        return;
    }

    // If the cache is full, make room by removing stalest element (index=0)
    while(aCache.length >= this.maxCacheEntries) {
        aCache.shift();
    }

    // Add to cache in the newest position, at the end of the array
    var oCacheElem = {request:oRequest,response:oResponse};
    aCache[aCache.length] = oCacheElem;
    this.fireEvent("responseCacheEvent", {request:oRequest,response:oResponse});
}
1275595
public function saveCacheListing()
    {

        if (md5(json_encode($this->cacheListing)) === $this->md5Sum) return false;

        return parent::set('cacheListing', $this->cacheListing);
    }
1347743
function ( oCache )
	{
		var
			s = this.fnGetSettings(),
			oMes = s.oMes,
			oWin = FixedHeader.oWin,
			oDoc = FixedHeader.oDoc,
			nTable = oCache.nWrapper,
			iTheadHeight = $("thead", s.nTable).outerHeight(),
			iCellHeight = $(nTable).outerHeight();

		if ( oWin.iScrollBottom < oMes.iTableBottom )
		{
			/* Below */
			this._fnUpdateCache( oCache, 'sPosition', 'absolute', 'position', nTable.style );
			this._fnUpdateCache( oCache, 'sTop', (oMes.iTableTop+oMes.iTableHeight-iCellHeight)+"px", 'top', nTable.style );
			this._fnUpdateCache( oCache, 'sLeft', oMes.iTableLeft+"px", 'left', nTable.style );
		}
		else if ( oWin.iScrollBottom < oMes.iTableBottom+oMes.iTableHeight-iCellHeight-iTheadHeight )
		{
			this._fnUpdateCache( oCache, 'sPosition', 'fixed', 'position', nTable.style );
			this._fnUpdateCache( oCache, 'sTop', (oWin.iHeight-iCellHeight)+"px", 'top', nTable.style );
			this._fnUpdateCache( oCache, 'sLeft', (oMes.iTableLeft-oWin.iScrollLeft)+"px", 'left', nTable.style );
		}
		else
		{
			/* Above */
			this._fnUpdateCache( oCache, 'sPosition', 'absolute', 'position', nTable.style );
			this._fnUpdateCache( oCache, 'sTop', (oMes.iTableTop+iCellHeight)+"px", 'top', nTable.style );
			this._fnUpdateCache( oCache, 'sLeft', oMes.iTableLeft+"px", 'left', nTable.style );
		}
	}
278445
function cacheCall(method, key) {
    return methodCache.call(method, key)
        .catch((err) => {
        log_1.logger.error(`[${method}] Error:`, err);
        throw err; // throw after log to stop async chain
    })
        .then((result) => {
        (result)
            ? log_1.logger.debug(`[${method}] Success: ${JSON.stringify(result)}`)
            : log_1.logger.debug(`[${method}] Success`);
        return result;
    });
}
384301
function ( oCache )
	{
		var
			s = this.fnGetSettings(),
			oMes = s.oMes,
			oWin = FixedHeader.oWin,
			oDoc = FixedHeader.oDoc,
			nTable = oCache.nWrapper,
			iCellWidth = $(nTable).outerWidth();

		if ( oWin.iScrollLeft < oMes.iTableLeft )
		{
			/* Fully left align */
			this._fnUpdateCache( oCache, 'sPosition', 'absolute', 'position', nTable.style );
			this._fnUpdateCache( oCache, 'sTop', oMes.iTableTop+"px", 'top', nTable.style );
			this._fnUpdateCache( oCache, 'sLeft', oMes.iTableLeft+"px", 'left', nTable.style );
		}
		else if ( oWin.iScrollLeft < oMes.iTableLeft+oMes.iTableWidth-iCellWidth )
		{
			this._fnUpdateCache( oCache, 'sPosition', 'fixed', 'position', nTable.style );
			this._fnUpdateCache( oCache, 'sTop', (oMes.iTableTop-oWin.iScrollTop)+"px", 'top', nTable.style );
			this._fnUpdateCache( oCache, 'sLeft', "0px", 'left', nTable.style );
		}
		else
		{
			/* Fully right align */
			this._fnUpdateCache( oCache, 'sPosition', 'absolute', 'position', nTable.style );
			this._fnUpdateCache( oCache, 'sTop', oMes.iTableTop+"px", 'top', nTable.style );
			this._fnUpdateCache( oCache, 'sLeft', (oMes.iTableLeft+oMes.iTableWidth-iCellWidth)+"px", 'left', nTable.style );
		}
	}
936500
function initHistoryArrayStack (routerBase) {
  let firstPageFullPath = window.location.href.replace(window.location.origin + routerBase, '/')

  try {
    // 如果localStorage中有历史访问记录，且最新一条和当前访问的是同一个页面
    // 那应该把之前的记录也加进来，主要解决在访问过程中刷新导致history列表丢失的问题
    let historyStack = JSON.parse(window.localStorage.getItem(MIP_HISTORY_ARRAY_STACK_LOCAL_KEY))
    if (
      historyStack &&
            historyStack.length &&
            historyStack[historyStack.length - 1] === firstPageFullPath
    ) {
      HISTORY_STACK = historyStack
    }
  } catch (err) {

  }

  // 首次访问的页面也要加入列表中
  if (HISTORY_STACK.indexOf(firstPageFullPath) === -1) {
    HISTORY_STACK.push(firstPageFullPath)
  }
}