Setup the cache based on the provided values for localCacheDir.
343395
def _setupCache(self):
        
        # we first check whether the cache directory exists. If it doesn't, create it.
        if not os.path.exists(self.localCacheDir):
            # Create a temporary directory as this worker's private cache. If all goes well, it
            # will be renamed into the cache for this node.
            personalCacheDir = ''.join([os.path.dirname(self.localCacheDir), '/.ctmp-',
                                        str(uuid.uuid4())])
            os.mkdir(personalCacheDir, 0o755)
            self._createCacheLockFile(personalCacheDir)
            try:
                os.rename(personalCacheDir, self.localCacheDir)
            except OSError as err:
                # The only acceptable FAIL case is that the destination is a non-empty directory
                # directory.  Assuming (it's ambiguous) atomic renaming of directories, if the
                # dst is non-empty, it only means that another worker has beaten this one to the
                # rename.
                if err.errno == errno.ENOTEMPTY:
                    # Cleanup your own mess.  It's only polite.
                    shutil.rmtree(personalCacheDir)
                else:
                    raise
        # You can't reach here unless a local cache directory has been created successfully
        with self._CacheState.open(self) as cacheInfo:
            # Ensure this cache is from the correct attempt at the workflow!  If it isn't, we
            # need to reset the cache lock file
            if cacheInfo.attemptNumber != self.workflowAttemptNumber:
                if cacheInfo.nlink == 2:
                    cacheInfo.cached = 0  # cached file sizes are accounted for by job store
                else:
                    allCachedFiles = [os.path.join(self.localCacheDir, x)
                                      for x in os.listdir(self.localCacheDir)
                                      if not self._isHidden(x)]
                    cacheInfo.cached = sum([os.stat(cachedFile).st_size
                                            for cachedFile in allCachedFiles])
                    # TODO: Delete the working directories
                cacheInfo.sigmaJob = 0
                cacheInfo.attemptNumber = self.workflowAttemptNumber
            self.nlinkThreshold = cacheInfo.nlink
649229
def _add_to_cache(key, value):
    
    if key in _CACHE:
        _CACHE[key].append(value)
    else:
        _CACHE[key] = [_PATTERN, value]
        _CACHE_COUNTER[key] = 0
141793
private static synchronized void addToCache(Cache cache, byte[] encoding,
            Object value) {
        if (encoding.length > ENC_MAX_LENGTH) {
            return;
        }
        Object key = new Cache.EqualByteArray(encoding);
        cache.put(key, value);
    }
425993
protected void initCaches(int cacheSize) {

        m_offlineJsps = CmsMemoryMonitor.createLRUCacheMap(cacheSize);
        m_onlineJsps = CmsMemoryMonitor.createLRUCacheMap(cacheSize);
    }
658878
public function put($key, $value, $duration, $localOnly = false)
    {
        $cacheKey = $this->cacheKey($key);
        if($this->keepLocalCache)
            $this->localCache[$cacheKey] = $value;
        if(!$localOnly)
            $this->cacheStore->put($cacheKey, $value, $duration);
    }
662280
@Nonnull
  public TypeaheadRemote setCache (@Nonnull final ETriState eCache)
  {
    m_eCache = ValueEnforcer.notNull (eCache, "Cache");
    return this;
  }
616320
protected void putToCache(String cacheName, String key, Object value) {
        putToCache(cacheName, key, value, 0);
    }
421803
def set(self, key, value, **kw):
        

        self.impl.set(key, value, **self._get_cache_kw(kw, None))
710297
def _cache_init(self):
        """"""
        cache_ = cache.get(self.CACHE_KEY)
        if cache_ is None:
            cache_ = defaultdict(dict)
        self._cache = cache_
1263259
def set(self, obj, build_kwargs):
        """"""
        if build_kwargs is None:
            build_kwargs = {}

        cached = {}
        if 'queryset' in build_kwargs:
            cached = {
                'model': build_kwargs['queryset'].model,
                'pks': list(build_kwargs['queryset'].values_list('pk', flat=True)),
            }

        elif 'obj' in build_kwargs:
            cached = {
                'obj': build_kwargs['obj'],
            }

        if not hasattr(self._thread_local, 'cache'):
            self._thread_local.cache = {}
        self._thread_local.cache[self._get_cache_key(obj)] = cached
556546
protected function _initCache()
    {
        if (!Cache::getConfig(static::$cacheConfig)) {
            Cache::setConfig(static::$cacheConfig, [
                'className' => $this->_getDefaultCacheConfigClassName(),
                'prefix' => static::$cacheConfig . '_' . $this->_identifier,
                'duration' => $this->getConfig('interval'),
            ]);
        }
    }
1300315
private static void initCaches() {

        if (m_cacheTemporary == null) {
            m_cacheTemporary = CmsMemoryMonitor.createLRUCacheMap(1024);

            m_cachePermanent = new ConcurrentHashMap<String, byte[]>(32);

            m_cacheContentDefinitions = CmsMemoryMonitor.createLRUCacheMap(CONTENT_DEFINITION_CACHE_SIZE);
        }
        if (OpenCms.getRunLevel() > OpenCms.RUNLEVEL_1_CORE_OBJECT) {
            if ((OpenCms.getMemoryMonitor() != null)
                && !OpenCms.getMemoryMonitor().isMonitoring(CmsXmlEntityResolver.class.getName() + ".cacheTemporary")) {
                // reinitialize the caches after the memory monitor is set up
                Map<String, byte[]> cacheTemporary = CmsMemoryMonitor.createLRUCacheMap(128);
                cacheTemporary.putAll(m_cacheTemporary);
                m_cacheTemporary = cacheTemporary;
                OpenCms.getMemoryMonitor().register(
                    CmsXmlEntityResolver.class.getName() + ".cacheTemporary",
                    cacheTemporary);

                Map<String, byte[]> cachePermanent = new ConcurrentHashMap<String, byte[]>(32);
                cachePermanent.putAll(m_cachePermanent);
                m_cachePermanent = cachePermanent;
                OpenCms.getMemoryMonitor().register(
                    CmsXmlEntityResolver.class.getName() + ".cachePermanent",
                    cachePermanent);

                Map<String, CmsXmlContentDefinition> cacheContentDefinitions = CmsMemoryMonitor.createLRUCacheMap(
                    CONTENT_DEFINITION_CACHE_SIZE);
                cacheContentDefinitions.putAll(m_cacheContentDefinitions);
                m_cacheContentDefinitions = cacheContentDefinitions;
                OpenCms.getMemoryMonitor().register(
                    CmsXmlEntityResolver.class.getName() + ".cacheContentDefinitions",
                    cacheContentDefinitions);
            }
        }
    }
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);
        }
    }
1159388
private void populateLocalCache() {
      CloseableIterator iterator = cache.keySet().iterator();
      try {
         while (iterator.hasNext()) {
            get(null, iterator.next());
         }
      } finally {
         iterator.close();
      }
   }
543131
def cache(self, obj):
        '''
        
        '''
        # Check cache path exists for current obj
        write_path = os.path.join( self.cache_path, obj.org_id )
        if not os.path.exists( write_path ): 
            mkdir_p( write_path )

        with open(os.path.join( write_path, obj.id ), 'wb') as f:
            pickle.dump( obj, f )
        
        # Add to localstore (keep track of numbers of objects, etc.)
        self.add_to_localstore(obj)   
        self.add_to_names(obj)
1123347
public void setCache(String cacheName, String cacheKey, Object object) {
        Cache cache = cacheManager.getCache(cacheName);
        if (cache == null) {
            return;
        }
        cache.put(new Element(cacheKey, object));
    }
869347
protected function setCache()
    {
        // Check if cache has expired
        if ($this->cache->expired() === false) {
            return;
        }

        // Instantiate values
        $values = array();

        // Get values from database
        foreach($this->database->table($this->config['table'])->get() as $setting)
        {
            $values[$setting->key] = json_decode($setting->value, true);
        }

        // Cache values
        $this->cache->set($values);
    }