Insert a file into the cache. If the cache is exceeding capacity,
then this call can, in turn, call backinto evictCache().
501379
void addCache(Path hdfsPath, Path localPath, long size) throws IOException {
    assert size == new File(localPath.toString()).length();
    assert size == fs.getFileStatus(hdfsPath).getLen();
    lookasideCache.addCache(hdfsPath, localPath, size);
  }
1168086
static void processFile(final IdentityPatchContext context, final File file, final PatchingTaskContext.Mode mode) throws IOException {
        if (mode == PatchingTaskContext.Mode.APPLY) {
            if (ENABLE_INVALIDATION) {
                updateJar(file, GOOD_ENDSIG_PATTERN, BAD_BYTE_SKIP, CRIPPLED_ENDSIG, GOOD_ENDSIG);
                backup(context, file);
            }
        } else if (mode == PatchingTaskContext.Mode.ROLLBACK) {
            updateJar(file, CRIPPLED_ENDSIG_PATTERN, BAD_BYTE_SKIP, GOOD_ENDSIG, CRIPPLED_ENDSIG);
            restore(context, file);
        } else {
            throw new IllegalStateException();
        }
    }
517974
protected void create(File cache) throws VictimsException {
        try {
            FileUtils.forceMkdir(cache);
        } catch (IOException e) {
            throw new VictimsException("Could not create an on disk cache", e);
        }
    }
815665
function add(src) {
      var defer = $q.defer();

      _checkImgCacheReady()
        .then(function() {
          ImgCache.cacheFile(src, function() {
            ImgCache.isCached(src, function(path, success) {
              defer.resolve(path);
            }, defer.reject);
          }, defer.reject);
        })
        .catch(defer.reject);

      return defer.promise;
    }
197034
def _tmpfile(self, cache_key, use):
    """"""
    with temporary_file(suffix=cache_key.id + use, root_dir=self._cache_root,
                        permissions=self._permissions) as tmpfile:
      yield tmpfile
525901
protected function setCache()
    {
        if ($this->cache) {
            $cacheFile = $this->getCacheFile();
            file_put_contents($cacheFile, $this->templateOutput);
        }
    }
828648
protected void pushState(final Cache<?, ?> cache) throws Exception {
      DataContainer<?, ?> dc = cache.getAdvancedCache().getDataContainer();
      dc.forEach(entry -> {
         MarshallableEntry me = ctx.getMarshallableEntryFactory().create(entry.getKey(), entry.getValue(), entry.getMetadata(),
               entry.getExpiryTime(), entry.getLastUsed());
         write(me);
      });
   }
1256187
def attach(self, upstream):
        """"""

        if upstream == self.last_upstream():
            raise Exception("Can't attach a cache to itself")

        self._prior_upstreams.append(self.last_upstream())

        self.last_upstream().upstream = upstream
51406
def _enforce_size_limit(self, capacity):
        """"""
        while len(self._cache) > capacity:
            key, value = self._cache.popitem(last=False)
            if self._on_evict is not None:
                self._on_evict(key, value)
392811
def cache(self, con):
        """"""
        self._lock.acquire()
        try:
            if not self._maxcached or len(self._idle_cache) < self._maxcached:
                con._reset(force=self._reset)  # rollback possible transaction
                # the idle cache is not full, so put it there
                self._idle_cache.append(con)  # append it to the idle cache
            else:  # if the idle cache is already full,
                con.close()  # then close the connection
            self._connections -= 1
            self._lock.notify()
        finally:
            self._lock.release()
486266
public function commitFileCache()
    {
        if (!empty($this->_aLockedFileHandles[LOCK_EX])) {
            startProfile("!__SAVING CACHE__! (warning)");
            foreach ($this->_aLockedFileHandles[LOCK_EX] as $sKey => $rHandle) {
                if ($rHandle !== false && isset($this->_aFileCacheContents[$sKey])) {
                    // #0002931A truncate file once more before writing
                    ftruncate($rHandle, 0);

                    // writing cache
                    fwrite($rHandle, $this->_processCache($sKey, $this->_aFileCacheContents[$sKey]));

                    // releasing locks
                    $this->_releaseFile($sKey);
                }
            }

            stopProfile("!__SAVING CACHE__! (warning)");

            //empty buffer
            $this->_aFileCacheContents = [];
        }
    }
963114
function handleFile(name, file, options, cache, callback) {
	var cachedData;
	if(!options || !options.settings || options.settings['view cache'] !== false) {
		cachedData = cache && cache.get(file);
	}
	if (!cachedData) {
		loadFile(file, function(err, fileData) {
			if (err) {
				return callback(err);
			}

			var partials;
			try {
				partials = findPartials(fileData);
			} catch (err) {
				return callback(err);
			}

			var data = {
				name: name,
				data: fileData,
				partials: partials
			};
			if (cache) {
				cache.set(file, data);
			}
			return callback(null, data);
		});
	}
	else {
		return callback(null, cachedData);
	}
}
1125793
def insert_chunk(self, id_):
        """"""

        assert_valid_chunk_id(id_)

        self.__fileobj.seek(self.__next_offset)
        self.__fileobj.write(pack('>4si', id_.ljust(4).encode('ascii'), 0))
        self.__fileobj.seek(self.__next_offset)
        chunk = IFFChunk(self.__fileobj, self[u'FORM'])
        self[u'FORM']._update_size(self[u'FORM'].data_size + chunk.size)

        self.__chunks[id_] = chunk
        self.__next_offset = chunk.offset + chunk.size
515779
def __cache(self, file, content, document):
        

        self.__files_cache.add_content(**{file: CacheData(content=content, document=document)})
1066877
private static void addCacheInfoUpdate(CacheStatus cacheStatus) {
    long cacheSize = cacheStatus.size;
    synchronized (baseDirSize) {
      Long dirSize = baseDirSize.get(cacheStatus.getBaseDir());
      if( dirSize == null ) {
        dirSize = Long.valueOf(cacheSize);
      } else {
        dirSize += cacheSize;
      }
      baseDirSize.put(cacheStatus.getBaseDir(), dirSize);
    }
    synchronized (baseDirNumberSubDir) {
      Integer dirSubDir = baseDirNumberSubDir.get(cacheStatus.getBaseDir());
      if( dirSubDir == null ) {
        dirSubDir = 1;
      } else {
        dirSubDir += 1;
      }
      baseDirNumberSubDir.put(cacheStatus.getBaseDir(), dirSubDir);
    }
  }
1040240
function addToCache(filename, obj) {
	if(cacheOn)
	{
		var x = cache[filename];
		if(!x)
			x = cache[filename] = {};
		x.mtime = obj.mtime || x.mtime;
		x.etag = obj.etag || x.etag;
		x.size = obj.size || x.size;
	}
}
181680
public void evictCache(Path hdfsPath, Path localPath, long size)
    throws IOException {
    boolean done = cacheFs.delete(localPath, false);
    if (!done) {
      if (LOG.isDebugEnabled()) {
        LOG.debug("Evict for path: " + hdfsPath +
                  " local path " + localPath + " unsuccessful.");
      }
    }
  }