Return whether to refresh an item synchronously when it is found in the
        cache but stale
505444
def should_stale_item_be_fetched_synchronously(self, delta, *args, **kwargs):
        
        if self.fetch_on_stale_threshold is None:
            return False
        return delta > (self.fetch_on_stale_threshold - self.lifetime)
336128
public boolean needsRefresh() {
        boolean needsRefresh;

        this.refreshLock.readLock().lock();
        long now = System.currentTimeMillis();
        long tokenDuration = (now - this.lastRefresh);
        needsRefresh = (tokenDuration >= this.expires - REFRESH_EPSILON);
        this.refreshLock.readLock().unlock();

        return needsRefresh;
    }
446430
private void blockingRefresh() {
        try {
            if (blockingRefreshLock
                    .tryLock(BLOCKING_REFRESH_MAX_WAIT_IN_SECONDS, TimeUnit.SECONDS)) {
                try {
                    // Return if successful refresh occurred while waiting for the lock
                    if (!shouldDoBlockingRefresh()) {
                        return;
                    } else {
                        // Otherwise do a synchronous refresh if the last lock holder was unable to
                        // refresh the value
                        refreshValue();
                        return;
                    }
                } finally {
                    blockingRefreshLock.unlock();
                }
            }
        } catch (InterruptedException ex) {
            handleInterruptedException("Interrupted waiting to refresh the value.", ex);
        }
        // Couldn't acquire the lock. Just try a synchronous refresh
        refreshValue();
    }
1174408
function updateItemUsage(self, oItem) {
			if (self._metadata.__byKey__[oItem.oData.key] != null) { // ItemData already exists, we need to remove the old position index
				var oldIndex = self._metadata.__byKey__[oItem.oData.key];
				delete self._metadata.__byIndex__[oldIndex];
				Log.debug("Cache Manager LRUPersistentCache: set/internalset - item already exists, so its indexes are updated");
			}
			self._metadata.__byIndex__[oItem.oData.lu] = oItem.oData.key;
			self._metadata.__byKey__[oItem.oData.key] = oItem.oData.lu;

			seekMetadataLRU(self);
		}
317841
def refresh(self, key, ttl, prev_value=None, prev_index=None,
                timeout=None):
        
        return self.adapter.set(key, ttl=ttl, refresh=True,
                                prev_value=prev_value, prev_index=prev_index,
                                timeout=timeout)
1138308
def _get_item_cache(self, item):
        """"""
        cache = self._item_cache
        res = cache.get(item)
        if res is None:
            values = self._data.get(item)
            res = self._box_item_values(item, values)
            cache[item] = res
            res._set_as_cached(item, self)

            # for a chain
            res._is_copy = self._is_copy
        return res
446341
def refresh(self):
        
        self._pre_action_check('refresh')
        if hasattr(self, 'id'):
            request = self.cypher("MATCH (n) WHERE id(n)={self}"
                                            " RETURN n")[0]
            if not request or not request[0]:
                raise self.__class__.DoesNotExist("Can't refresh non existent node")
            node = self.inflate(request[0][0])
            for key, val in node.__properties__.items():
                setattr(self, key, val)
        else:
            raise ValueError("Can't refresh unsaved node")
675594
@Override
    public CompletableFuture<Void> refreshAsync(String key, int expireSeconds) {
        return setExpireSecondsAsync(key, expireSeconds);
    }
170969
protected void refreshItem(CacheItem item, Cache cache) throws Exception {
        CacheLoader loader = item.getLoader();
        Object[] loaderParams = item.getLoaderParams();

        if (loader == null) {
            throw new InternalCacheEngineException("No cache loader for " + getScopeAndKeyString(item));
        }

        if (logger.isDebugEnabled()) {
            logger.debug("Refreshing " + getScopeAndKeyString(item));
        }

        Object newValue = loader.load(loaderParams);
        if (newValue != null) {
            cache.put(item.getScope(), item.getKey(), newValue, item.getTicksToExpire(), item.getTicksToRefresh(),
                      item.getLoader(), item.getLoaderParams());
        } else {
            // If newValue returned is null, remove the item from the cache
            cache.remove(item.getScope(), item.getKey());
        }
    }
113143
private synchronized void checkCache()
    {
        Object[] pTables = m_setTableCacheList.toArray();
        for (Object objTable : pTables)
        {
            PTable pTable = (PTable)objTable;
            if (pTable.addPTableOwner(null) == 1)
            { // Not currently being used is a candidate for flushing from the cache.
                long lTimeLastUsed = pTable.getLastUsed();
                long lTimeCurrent = System.currentTimeMillis();
                if ((lTimeCurrent - lTimeLastUsed) > (this.getCacheMinutes() * 60 * 1000))
                {
                    pTable.removePTableOwner(this, true);
                    m_setTableCacheList.remove(pTable);
                }
            }
        }
    }
690805
def sync(self, clear_cache=False):
        
        self.persistence.update(self)

        if clear_cache:
            self.cache.clear()
3800
function () {
		return utility.iterate( cache.items, function ( v, k ) {
			if ( cache.expired( k ) ) {
				cache.expire( k, true );
			}
		});
	}
403624
def _update_inplace(self, result, verify_is_copy=True):
        
        # NOTE: This does *not* call __finalize__ and that's an explicit
        # decision that we may revisit in the future.

        self._reset_cache()
        self._clear_item_cache()
        self._data = getattr(result, '_data', result)
        self._maybe_update_cacher(verify_is_copy=verify_is_copy)
227556
function MustUseCache()
    {
        if ($this->cacheLifetime == 0)
        {
            return false;
        }
        if (!File::Exists($this->file))
        {
            return false;
        }
        $now = Date::Now();
        $lastMod = File::GetLastModified($this->file);
        if ($now->TimeStamp() - $lastMod->TimeStamp() < $this->cacheLifetime)
        {
            return true;
        }
        return false;
    }
65031
function meta_data_still_fresh(item) {
    var promise = read_meta_data(item).
    then(function(item) {
        return new Promise(function(resolve, reject) {
            if (headers_still_fresh(item.meta_data.headers)) {
                resolve(item);
            } else {
                reject(item);
            }
        });
    });

    return promise;
}
448452
def refresh_if_needed(self):
        
        if self.state in (self.PENDING, self.STARTED):
            try:
                response, = self._fetch_result()['tasks']
            except (KeyError, ValueError):
                raise Exception(
                    "Unable to find results for task."
                )

            if 'error' in response:
                self.state == self.FAILURE
                raise ServerError(response['error'])

            if 'state' in response:
                self.state = response['state']
                self.result = response['result']
490281
def check_cached_item(self, path):
        
        item_path = '%s/%s' % (
                self.cache_folder,
                path.strip('/')
            )

        if self.blob_service.exists(self.container_name, item_path):
            return self._generate_url(item_path)
        else:
            return False