本文整理汇总了PHP中Illuminate\Cache\CacheManager::put方法的典型用法代码示例。如果您正苦于以下问题:PHP CacheManager::put方法的具体用法?PHP CacheManager::put怎么用?PHP CacheManager::put使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Illuminate\Cache\CacheManager
的用法示例。
在下文中一共展示了CacheManager::put方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: put
public function put($request, $file)
{
if ($file) {
$this->cache->put($this->makeCacheKey($request), $file, Carbon::now()->addMinutes(env('CACHE_EXPIRE_MINUTES')));
}
return $this;
}
示例2: put
/**
* Put a key value pair in the cache
*
* @param string $key
* @param mixed $value
* @param integer $minutes
*
* @return mixed
*/
public function put($key, $value, $minutes = null)
{
if (is_null($minutes)) {
$minutes = $this->minutes;
}
return $this->cache->put($key, $value, $minutes);
}
示例3: nextAndPreventReplay
/**
* Prevent further posts with the same signature
*
* @return mixed
*/
protected function nextAndPreventReplay(Closure $next)
{
$response = $next($this->request);
$expire = Carbon::createFromTimestamp($this->request->get('timestamp'))->addHours($this->cacheDays * 24);
$this->cache->put($this->getCacheKey(), 1, $expire);
return $response;
}
示例4: storeReturnUrl
/**
* Store a return url in the cache if provided.
*
* @param TemporaryCredentials $temp
*
* @return void
*/
protected function storeReturnUrl(TemporaryCredentials $temp)
{
if ($url = $this->request->get('return_url')) {
$key = 'oauth_return_url_' . $temp->getIdentifier();
$this->cache->put($key, $url, ProviderContract::CACHE_TTL);
}
}
示例5: put
/**
* Put
* @param $key
* @param $value
* @param null $minutes
* @return mixed
*/
public function put($key, $value, $minutes = null)
{
if (is_null($minutes)) {
$minutes = $this->minutes;
}
if ($this->cacheDriver == "file") {
return $this->cache->put($key, $value, $minutes);
}
return $this->cache->tags($this->tag)->put($key, $value, $minutes);
}
示例6: render
/**
* Render the homepage view for displaying.
*
* @param string $name
* @return string
*/
public function render($name, $subname = 'Home.Content')
{
if ($this->cache->has('home.content')) {
$content = $this->cache->get('home.content');
} else {
$slides = App::make('Lib\\Slides\\SlideRepository')->get();
$news = App::make('Lib\\News\\NewsRepository')->latest(8);
$content = $this->view->make($subname)->with('slides', $slides)->with('news', $news)->with('categories', $this->getCategories())->render();
$this->cache->put('home.content', $content, 2880);
}
return $this->view->make($name)->with('content', $content);
}
示例7: setCacheLocale
/**
* Sets a cache key to the specified locale.
*
* @param Model $locale
*/
protected function setCacheLocale(Model $locale)
{
if (!$this->cache->has($locale->code)) {
$id = sprintf('translation.%s', $locale->code);
$this->cache->put($id, $locale, $this->cacheTime);
}
}
示例8: compileScriptMaterial
/**
* @return \Illuminate\Support\Collection
*/
protected function compileScriptMaterial()
{
$files = new Collection();
$this->layoutJsMaterial->merge($this->defaultJsMaterial)->merge($this->extendJsMaterial)->each(function ($value) use($files) {
$files->push($this->findPath($value));
});
$code = md5($files);
$this->dispatcher->listen('kernel.handled', function () use($code, $files) {
$dictionary = new Collection();
$dictionary->push($this->application->publicPath());
$dictionary->push('cache');
$dictionary = $this->pathSplit($code, '2,2,2,2,2,2', $dictionary);
$dictionary = $dictionary->implode(DIRECTORY_SEPARATOR);
if (!$this->files->isDirectory($dictionary)) {
$this->files->makeDirectory($dictionary, 0755, true, true);
}
$file = $dictionary . DIRECTORY_SEPARATOR . Str::substr($code, 12, 20) . '.js';
$key = 'cache.script.' . $code;
if (!$this->files->exists($file) || !$this->cache->has($key) && $this->application->inDebugMode()) {
$content = $this->compileScript($files);
$expires = Carbon::now()->addMinutes(10);
$this->cache->put($key, $content, $expires);
file_put_contents($file, $content);
}
});
return $this->pathSplit($code, '2,2,2,2,2,2,20', Collection::make(['cache']))->implode('/') . '.js';
}
示例9: generate
/**
* Render weather widget.
*
* @param array $options
* @return string
*/
public function generate($options = array())
{
// Get options
$options = array_merge($this->config['defaults'], $options);
// Unify units
$options['units'] = strtolower($options['units']);
if (!in_array($options['units'], array('metric', 'imperial'))) {
$options['units'] = 'imperial';
}
// Create cache key
$cacheKey = 'Weather.' . md5(implode($options));
// Check cache
if ($this->config['cache'] && $this->cache->has($cacheKey)) {
return $this->cache->get($cacheKey);
}
// Get current weather
$current = $this->getWeather($options['query'], 0, $options['units'], 1);
if ($current['cod'] !== 200) {
return 'Unable to load weather';
}
// Get forecast
$forecast = $this->getWeather($options['query'], $options['days'], $options['units']);
// Render view
$html = $this->view->make("{$this->config['views']}.{$options['style']}", array('current' => $current, 'forecast' => $forecast, 'units' => $options['units'], 'date' => $options['date']))->render();
// Add to cache
if ($this->config['cache']) {
$this->cache->put($cacheKey, $html, $this->config['cache']);
}
return $html;
}
示例10: registerCollectionCache
/**
* Register the collections cache and store each of the cached items on
* the collection.
*
* @return \JasonLewis\Website\DocumentCollection
*/
public function registerCollectionCache()
{
// If the cache does not contain the items identifier then we'll use the loader
// to load all items and store the items in the cache.
$items = $this->cache->remember($this->identifier, $this->expires, function () {
$items = $this->loader->load();
// Spin over each of the items and store the individual articles in the cache
// as well so that when we request a single item we can quickly pull it from
// the cache.
foreach ($items as $item) {
$this->cache->put($item->getSlug(), $item, $this->expires);
}
return $items;
});
// With the cached items we'll now spin over each one and using the array access
// assign it to our document collection.
foreach ($items as $item) {
$this[$item->getSlug()] = $item;
}
return $this;
}
示例11: getPrice
/**
* Return the price of an item using Steam's API
*
* @param integer $appId
* @param string $itemName
* @param bool $onlyPrice Return only the lowest price
* @return stdClass
*/
public function getPrice($appId = 730, $itemName, $onlyPrice = false)
{
$cacheKey = 'steamprice.item.' . str_slug($itemName);
// Check if item price is cached
if ($this->cache->has($cacheKey)) {
$data = $this->cache->get($cacheKey);
} else {
// Grab the item price and cache it
$url = $this->getItemPriceUrl($itemName, $appId);
// No result
if (!($json = @file_get_contents($url))) {
// Cache null for 30 seconds to not harass the Steam servers
$this->cache->put($cacheKey, null, 30);
return null;
}
$json = str_replace($this->currencyHtmlTags, '', $json);
$data = json_decode($json);
$this->cache->put($cacheKey, $data, Config::get('braseidon.steam-item-prices.cache_time'));
}
if ($onlyPrice === true) {
$data = !isset($data->lowest_price) ? null : $data->lowest_price;
}
return $data;
}
示例12: updateRememberToken
/**
* Update the "remember me" token for the given user in storage.
*
* @param \Illuminate\Contracts\Auth\Authenticatable $user
* @param string $token
* @return void
*/
public function updateRememberToken(Authenticatable $user, $token)
{
$this->cache->put('user' . $user->getAuthIdentifier() . '_token_' . $token, $user, 60 * 24);
}
示例13: set
/**
* Adds/updates a setting.
*
* @param string $key
* @param string $value
* @return void
*/
public function set($key, $value)
{
// update the local cache
$this->settings[$key] = $value;
$this->cache->put($this->key($key), $value, 0);
}
示例14: put
/**
* Store an item in the cache for a given number of minutes.
*
* @param string $key
* @param mixed $value
* @param int $minutes
*/
public function put($key, $value, $minutes)
{
$this->cache->put($this->prefix . $key, $value, $minutes);
}
示例15: updateRememberToken
/**
* Update the "remember me" token for the given user in storage.
*
* @param \Illuminate\Auth\UserInterface $user
* @param string $token
* @return void
*/
public function updateRememberToken(UserInterface $user, $token)
{
//We use the cache because it's easier than managing old file deletion.
//Such a micro functionnality souldn't expect more than 24 hours autologin
$this->cache->put('user' . $user->getAuthIdentifier() . '_token_' . $token, $user, 60 * 24);
}