Stores the cached data in /private/cache filesystem
484760
public function store($key, $data, $lifetime = 0)
    {
        $file_path = $this->getFilePath($key);
        $dir = \dirname($file_path);

        if (!is_dir($dir)) {
            try {
                \mkdir($dir, 0777, true);
            } catch (Exception $e) {
                throw new \Exception('Could create cache directory: ' . $file_path . " - " . $e->getMessage());
            }
        }

        try {
            $fh = \fopen($file_path, 'a+');
        } catch (\Exception $e) {
            throw new \Exception('Could not write to cache: ' . $file_path . " - " . $e->getMessage());
        }

        //exclusive lock
        \flock($fh, LOCK_EX);

        \fseek($fh, 0);

        \ftruncate($fh, 0);

        if ($lifetime != 0) {
            $lifetime = time() + $lifetime;
        }

        $data = \serialize(array($lifetime, $data));

        if (\fwrite($fh, $data) === false) {
            throw new \Exception('Could not write to cache: ' . $file_path);
        }

        \fclose($fh);

        if ($key != $this->catalog_key) {
            $this->catalogKeyAdd($key, $lifetime);
        }
        return true;
    }
158821
def _save_cache_to_file(self):
        '''
        
        '''
        if self._cache_dir is None:
            raise DataSourceWithFileCacheError(
                'Use this class with "with statement" if you don\'t specify cache dir.')
        cache_data = OrderedDict()

        def get_data(args):
            pos = args[0]
            q = args[1]
            retry = 1
            while True:
                if retry > 10:
                    logger.log(
                        99, '_get_current_data() retry count over give up.')
                    raise
                d = self._data_source._get_data(pos)
                if d is not None:
                    break
                logger.log(99, '_get_data() fails. retrying count {}/10.'.format(
                           retry))
                retry += 1

            q.put((pos, d))

        q = Queue()
        with closing(ThreadPool(processes=self._num_of_threads)) as pool:
            pool.map(get_data, [(pos, q) for pos in self._cache_positions])

        while len(cache_data) < len(self._cache_positions):
            index, data = q.get()
            cache_data[index] = data
        start_position = self.position - len(cache_data) + 1
        end_position = self.position
        cache_filename = os.path.join(
            self._cache_dir, '{}_{:08d}_{:08d}{}'.format(self._cache_file_name_prefix,
                                                         start_position,
                                                         end_position,
                                                         self._cache_file_format))

        data = OrderedDict([(n, []) for n in self._data_source.variables])
        for pos in sorted(cache_data):
            cd = cache_data[pos]
            for i, n in enumerate(self._data_source.variables):
                if isinstance(cd[i], numpy.ndarray):
                    d = cd[i]
                else:
                    d = numpy.array(cd[i]).astype(numpy.float32)
                data[n].append(d)

        logger.info('Creating cache file {}'.format(cache_filename))
        try:
            if self._cache_file_format == ".h5":
                h5 = h5py.File(cache_filename, 'w')
                for k, v in data.items():
                    h5.create_dataset(k, data=v)
                h5.close()
            else:
                retry_count = 1
                is_create_cache_imcomplete = True
                while is_create_cache_imcomplete:
                    try:
                        with open(cache_filename, 'wb') as f:
                            for v in data.values():
                                numpy.save(f, v)
                        is_create_cache_imcomplete = False
                    except OSError:
                        retry_count += 1
                        if retry_count > 10:
                            raise
                        logger.info(
                            'Creating cache retry {}/10'.format(retry_count))
        except:
            logger.critical(
                'An error occurred while creating cache file from dataset.')
            for k, v in data.items():
                size = v[0].shape
                for d in v:
                    if size != d.shape:
                        logger.critical('The sizes of data "{}" are not the same. ({} != {})'.format(
                            k, size, d.shape))
            raise

        self._cache_file_names.append(cache_filename)
        self._cache_file_order.append(len(self._cache_file_order))
        self._cache_file_data_orders.append(list(range(len(cache_data))))
        self._cache_positions = []
631873
def configure_cache
      Jekyll::Cache.cache_dir = in_source_dir(config["cache_dir"], "Jekyll/Cache")
      Jekyll::Cache.disable_disk_cache! if safe
    end
353281
function Persist(cacheFile, keys, log) {
  var pdata = (cacheFile) ? JSON.parse(fs.readFileSync(cacheFile, 'utf8')) : {}
    , guid = makeGuid(keys);

  pdata[guid] = pdata[guid] || {};

  // this is the only member that needs access to the full object and the file
  this.save = function () {
    if (cacheFile) {
      fs.writeFileSync(cacheFile, JSON.stringify(pdata));
    }
  };

  // members need only know their config object
  this.cfg = pdata[guid];
  this.cfg.opts = this.cfg.opts || {};

  // was a logger passed down?
  this.log = (type.isFunction(log)) ? log : noop;
}
139780
def write(self):
        
        io.debug("Storing cache '{0}'".format(self.path))
        with open(self.path, "w") as file:
            json.dump(self._data, file, sort_keys=True, indent=2,
                      separators=(',', ': '))
228476
def cache_set(cache_dir, cache_key, content):
    
    filename = os.path.join(cache_dir, cache_key)

    with open(filename, 'w') as f:
        f.write(content)
901519
function store()
    {
        if ( !$this->IsModified )
        {
            return;
        }

        // EZP-23908: Restore timestamps before saving, to reduce chance of race condition issues
        $modifiedTimestamps = $this->Timestamps;
        $this->restore();

        // Apply timestamps that have been added or modified in this process
        foreach ( $modifiedTimestamps as $name => $value )
        {
            if ( $value > self::getTimestamp( $name, 0 ) )
            {
                $this->setTimestamp( $name, $value );
            }
        }

        if ( $this->IsModified )
        {
            $this->CacheFile->storeContents( "<?php\n\$Timestamps = " . var_export( $this->Timestamps, true ) . ";\n?>", 'expirycache', false, true );
            $this->IsModified = false;
        }
    }
684280
def save_data(self):
        """"""
        filename = os.path.join(
            self._get_prefix(),
            self.model.site
        )
        self.store.store_json(
            filename,
            self.model.get_dict()
        )
802400
def write_to_cache(self, data, filename=''):
        '''  '''
        if not filename:
            filename = self.cache_path_cache
        json_data = json.dumps(data)
        with open(filename, 'w') as cache:
            cache.write(json_data)
        return True
1275595
public function saveCacheListing()
    {

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

        return parent::set('cacheListing', $this->cacheListing);
    }
515779
def __cache(self, file, content, document):
        

        self.__files_cache.add_content(**{file: CacheData(content=content, document=document)})
798580
private function saveData(): bool
    {
        if ($cacheTime = $this->getMeta()->getCache()) {
            return Cache::set(
                $this->key,
                $this->getData(),
                $cacheTime,
                ['system', 'data']
            );
        }
        return false;
    }
332340
def CacheFileSystem(self, path_spec, file_system):
    
    identifier = self._GetFileSystemCacheIdentifier(path_spec)
    self._file_system_cache.CacheObject(identifier, file_system)
353927
def save_cache(data, filename):
    """"""
    with open(filename, 'wb') as handle:
        pickle.dump(data, handle)
310979
def _save_cache(self):
        """"""
        if not self._disable_cache:
            UTILS.save_cache(self._cache, self._cache_path)
1362736
def store(self, loc, df):
        

        path = "%s.%s" % (self._root / "processed" / loc, FILE_EXTENSION)
        WRITE_DF(df, path, **WRITE_DF_OPTS)
        self._cache[loc] = df
670823
def put_cache(self, minions):
        '''
        
        '''
        self.cupd_out.send(self.serial.dumps(minions))