Checks if cache is expired

@param  string $fromCurrency
@param  string $toCurrency
@return bool
542962
protected function isCacheExpired($fromCurrency, $toCurrency)
    {
        $cacheCreationTime = $this->getCacheCreationTime($fromCurrency, $toCurrency);
        return (time() - $cacheCreationTime) > $this->getCacheTimeOut()->format('%s');
    }
1103300
protected function addUpdateExchangeRate($currencyFrom, $currencyTo, $rate)
    {
        if (!in_array($currencyTo, $this->managedCurrencies)) {
            return false;
        }
        
        $exchangeRate = $this->currencyRateRepository->findOneBy([
            'currencyFrom' => $currencyFrom,
            'currencyTo'   => $currencyTo,
        ]);
        
        if (null === $exchangeRate) {
            $exchangeRate = new CurrencyRate();
            $exchangeRate->setCurrencyFrom($currencyFrom);
            $exchangeRate->setCurrencyTo($currencyTo);
            $exchangeRate->setExchangeRate($rate);
            $this->helper->getEntityManager()->persist($exchangeRate);
        } else {
            $exchangeRate->setExchangeRate($rate);
        }
        
        return true;
    }
29078
public function migrateExpiredJobs($from, $to)
    {
        $options = ['cas' => true, 'watch' => $from, 'retry' => 10];

        $this->getConnection()->transaction($options, function ($transaction) use ($from, $to)
        {
            // First we need to get all of jobs that have expired based on the current time
            // so that we can push them onto the main queue. After we get them we simply
            // remove them from this "delay" queues. All of this within a transaction.
            $jobs = $this->getExpiredJobs(
                $transaction, $from, $time = $this->getTime()
            );

            // If we actually found any jobs, we will remove them from the old queue and we
            // will insert them onto the new (ready) "queue". This means they will stand
            // ready to be processed by the queue worker whenever their turn comes up.
            if (count($jobs) > 0) {
                $this->removeExpiredJobs($transaction, $from, $time);

                $this->pushExpiredJobsOntoNewQueue($transaction, $to, $jobs);
            }
        });
    }
279669
public function set($key, $value, $duration) {
        X::logger()->trace("CCache set $key expire in $duration");
        $file = $this->key2file($key);
        $content = array(
            'key'        => $key,
            'expiration' => $duration > 0 ? time() + $duration : 0,
            'data'       => $value,
        );
        $phpCode = '<?php return ' . Toolkit::compile($content) . ';';
        if (function_exists('opcache_invalidate')) {
            opcache_invalidate($file, true);
        }
        file_put_contents($file, $phpCode, LOCK_EX);
    }
780213
public function isExpired($key)
    {
        // Check to see if the cached data has expired.
        if (filemtime($this->fetchStreamUri($key)) < (time() - $this->ttl)) {
            return true;
        }

        return false;
    }
564065
public function gc($past)
    {
        // delete the session records that have expired
        $sql = "DELETE FROM {$this->options['table']} WHERE {$this->options['time_col']} < :time";

        try {
            $stmt = $this->db->prepare($sql);

            $stmt->bindValue(':time', $past, \PDO::PARAM_INT);

            $stmt->execute();
        } catch (\PDOException $e) {
            throw new \RuntimeException(
                sprintf(
                    'PDOException was thrown when trying to delete expired sessions: %s',
                    $e->getMessage()
                ),
                0,
                $e
            );
        }

        return true;
    }
405147
public function canSend($to)
	{
		$this->setKey($to);

		$code = $this->storage->get($this->key, '');

		if (empty($code) || $code->sentAt < Carbon::now()->addMinutes(-1)) {
			return true;
		}

		return false;
	}
941171
public function exchange($from, $to, $amount = 1) {
        return $this->getExchange()->setHeader([
            'apikey' => $this->get('apikey')
        ])->parameters([
            'fromCurrency' => $from,
            'toCurrency' => $to,
            'amount' => $amount
        ])->json();
    }
573666
private function isBetween($timestamp, $fromTime, $toTime, $format = 'Hi')
    {
        $dateTime = new DateTime();
        $timezone = new DateTimeZone('UTC');
        $dtRef = $dateTime->createFromFormat('U', $timestamp, $timezone);
        $dtFrom = $dateTime->createFromFormat($format, $fromTime, $timezone);
        $dtTo = $dateTime->createFromFormat($format, $toTime, $timezone);
        if ($dtFrom > $dtTo) {
            $dtTo->modify('+1 day');
        }
        return (
                $dtFrom <= $dtRef &&
                $dtRef <= $dtTo
            ) || (
                $dtFrom <= $dtRef->modify('+1 day') &&
                $dtRef <= $dtTo
            );
    }
1094967
def update_cache(from_currency, to_currency):
	
	if check_update(from_currency, to_currency) is True:
		ccache[from_currency][to_currency]['value'] = convert_using_api(from_currency, to_currency)
		ccache[from_currency][to_currency]['last_update'] = time.time()
		cache.write(ccache)
847128
protected function checkTable(Table $fromTable, Table $toTable)
    {
        $tableName = $fromTable->getName();
        $diff = (new Comparator())->diffTable($fromTable, $toTable);
        if ($diff !== false) {
            $this->removeIgnoredChanges($diff);
            $this->diffs[$tableName] = $diff;
        }
    }
702817
public function expired($onSessionExpires = false)
    {
        if (!$this->_data['expires'] && $onSessionExpires) {
            return true;
        }

        return $this->_data['expires'] < time() && $this->_data['expires'];
    }
788365
public function isBetweenInclusive(ZonedDateTime $from, ZonedDateTime $to) : bool
    {
        return $this->isAfterOrEqualTo($from) && $this->isBeforeOrEqualTo($to);
    }
1117011
@Override
	public void cacheResult(CommerceCurrency commerceCurrency) {
		entityCache.putResult(CommerceCurrencyModelImpl.ENTITY_CACHE_ENABLED,
			CommerceCurrencyImpl.class, commerceCurrency.getPrimaryKey(),
			commerceCurrency);

		finderCache.putResult(FINDER_PATH_FETCH_BY_UUID_G,
			new Object[] {
				commerceCurrency.getUuid(), commerceCurrency.getGroupId()
			}, commerceCurrency);

		finderCache.putResult(FINDER_PATH_FETCH_BY_G_C,
			new Object[] {
				commerceCurrency.getGroupId(), commerceCurrency.getCode()
			}, commerceCurrency);

		commerceCurrency.resetOriginalValues();
	}
548440
function(from, to) {
					from = frontSlash(from);
					to = frontSlash(to);
					if (this.exists(from)) {
						cache[to] = cache[from];
						cache[to].path = to;
						cache[from] = null;
						delete cache[from];
						return true;
					}
				}
1100045
private function _checkExpired($timestamp, $expiration) {
    $result = false;
    if ($expiration !== 0) {
      $timeDiff = time() - $timestamp;
      ($timeDiff > $expiration) ? $result = true : $result = false;
    }
    return $result;
  }
603377
public function isExpired($now = null)
    {
        if ($now === null) { $now = time();
        }
        if (is_int($this->expires) && $this->expires < $now) {
            return true;
        } else {
            return false;
        }
    }