本文整理汇总了PHP中Illuminate\Cache\Repository::put方法的典型用法代码示例。如果您正苦于以下问题:PHP Repository::put方法的具体用法?PHP Repository::put怎么用?PHP Repository::put使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Illuminate\Cache\Repository
的用法示例。
在下文中一共展示了Repository::put方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: put
/**
* Cache the key value till 12am
*
* @param string $key
* @param mixed $value
* @return void
*/
public static function put($key, $value)
{
$today = strtotime(date('Ymd'));
$key = "{$today}.{$key}";
$minutes = (int) date('i');
$total_minutes_today = date('G') * 60 + $minutes;
$minutes_till_midnight = 1440 - $total_minutes_today;
static::$cache->put($key, $value, $minutes_till_midnight);
}
示例2: postAuthorized
/**
* Handles authenticating that a user/character is still valid.
*
* @return \Illuminate\Http\JsonResponse
*/
public function postAuthorized()
{
// Get the neccessary headers from the request.
$service = $this->request->header('service', false);
$username = $this->request->header('username', '');
$character = $this->request->header('character', '');
$this->log->info('A service is attempting to validate a user.', ['username' => $username, 'character' => $character, 'service' => $service]);
// Verify that the external service exists in the configuration.
if (!$service || !$this->config->get("addon.auth.{$service}")) {
$this->log->info(self::ERROR_INVALID_EXTERNAL_SERVICE, ['service' => $service]);
return $this->failure(self::ERRNO_INVALID_EXTERNAL_SERVICE, self::ERROR_INVALID_EXTERNAL_SERVICE);
}
// Check the cache first so the api isn't hammered too badly.
$key = 'auth:session:' . sha1("{$service}:{$username}");
if ($this->cache->has($key)) {
$this->log->info('Returning the cached authorization result.');
return $this->cache->get($key);
}
// Attempt to find the requested user.
$identifier = filter_var($username, FILTER_VALIDATE_EMAIL) ? 'email' : 'name';
$user = $this->users->where($identifier, $username)->first() ?: false;
if (!$user) {
$this->log->info(self::ERROR_USER_NOT_FOUND);
return $this->failure(self::ERRNO_USER_NOT_FOUND, self::ERROR_USER_NOT_FOUND);
}
// Get and cache the response for 15 minutes.
$response = $this->getLoginResult($user, $service, $character);
$this->cache->put($key, $response, $this->carbon->now()->addMinutes(15));
return $response;
}
示例3: image
public function image(Repository $cache, $id)
{
if ($cache->has($id)) {
return $cache->get($id);
}
$card = base64_encode(file_get_contents('http://magiccards.info/scans/en/ori/' . $id . '.jpg'));
$cache->put($id, $card, 60);
return $card;
}
示例4: saveCachedView
/**
* Save a cached view if caching is enabled.
*
* @param \Illuminate\Http\Response $response
* @return void
*/
protected function saveCachedView(Response $response)
{
if (config('sitemap.cache_enabled')) {
$key = $this->getCacheKey();
$content = $response->getOriginalContent()->render();
if (!$this->cache->get($key)) {
$this->cache->put($key, $content, config('sitemap.cache_length'));
}
}
}
示例5: make
/**
* Generate thumbnail.
*
* @param $src
* @param $width
* @param $height
*
* @throws \RuntimeException
* @return Thumbnail
*/
public function make($src, $width, $height)
{
if ($src === null || $width === null && $height === null) {
throw new \RuntimeException();
}
$key = md5($src . 'w' . $width . 'h' . $height);
if (!($image = $this->cache->get($key))) {
$image = $this->image->make($src);
$image->resize($width, $height, function ($constraint) {
$constraint->aspectRatio();
$constraint->upsize();
});
if ($width === null) {
$width = $image->getWidth();
}
if ($height === null) {
$height = $image->getHeight();
}
$image->resizeCanvas($width, $height, 'center', false, 'ffffff');
$image = (string) $image->encode('jpg');
$this->cache->put($key, $image, $this->lifetime);
}
return new Thumbnail($key, $image, $this->expires(), 'image/jpeg');
}
示例6: put
/**
* Store an item in the cache.
*
* @param string $key
* @param mixed $value
* @param \DateTime|int $minutes
* @return void
* @static
*/
public static function put($key, $value, $minutes)
{
\Illuminate\Cache\Repository::put($key, $value, $minutes);
}
示例7: put
/**
* Store an item in the cache.
*
* @param mixed $key
* @param mixed $value
* @param \DateTime|int $minutes
* @return void
*/
public function put($key, $value, $minutes)
{
if (is_array($key) && is_array($value)) {
$this->putMany(array_combine($key, $value), $minutes);
} else {
parent::put($key, $value, $minutes);
}
}
示例8: put
/**
* @param string $key
* @param \Illuminate\Http\Response $response
* @param \DateTime|int $minutes
*/
public function put($key, $response, $minutes)
{
$this->cache->put($key, $this->responseSerializer->serialize($response), $minutes);
}
示例9: write
/**
* {@inheritDoc}
*/
public function write($sessionId, $data)
{
return $this->cache->put($sessionId, $data, $this->minutes);
}
示例10: putCodeToCache
/**
* 保存验证码到缓存中
* @param string $mobile
* @param string $code
* @param string $bag
* @return \Illuminate\Cache\void
*/
public function putCodeToCache($mobile, $code, $bag)
{
$key = $this->getCacheKey($mobile, $bag);
return $this->store->put($key, $code, $this->cacheMinutes);
}
示例11: setToken
/**
* Setter for token
*
* @param string $key
* @param string $value
* @param int $duration
*/
public function setToken($key, $value, $duration = 60)
{
$this->cache->put('reactor.tokens.' . $key, $value, $duration);
}
示例12: put
/**
* @param $content
* @return mixed
*/
public function put($key, $content)
{
if ($this->enabled) {
return $this->cache->put($key, $content, $this->getCacheLifetime());
}
}
示例13: updateInverseIndex
/**
* Updates the inverse index for the given cache key.
*
* @param string $key
* @param \DateTime|int|null $minutes
*/
protected function updateInverseIndex($key, $minutes = null)
{
$this->setKeywordsOperation(true);
$keywordsState = $this->determineKeywordsState($key);
$inverseIndexKey = $this->generateInverseIndexKey($key);
if (empty($keywordsState['new'])) {
parent::forget($inverseIndexKey);
} elseif ($keywordsState['old'] != $keywordsState['new']) {
$newInverseIndex = array_values($keywordsState['new']);
is_null($minutes) ? parent::forever($inverseIndexKey, $newInverseIndex) : parent::put($inverseIndexKey, $newInverseIndex, $minutes);
}
$this->setKeywordsOperation(false);
}
示例14: put
/**
* Store an item in the cache.
*
* @param string $key
* @param mixed $value
* @param \DateTime|int $minutes
*
* @return void
*/
public function put($key, $value, $minutes)
{
if ($this->enabled) {
$this->cache->put($key, $value, $minutes);
}
}
示例15: storeResultInCache
/**
* @param $result
*/
public function storeResultInCache($result)
{
$this->cache->put($this->actualQueryHash, $result, $this->cacheLifeTime);
}