本文整理汇总了PHP中Cache::forget方法的典型用法代码示例。如果您正苦于以下问题:PHP Cache::forget方法的具体用法?PHP Cache::forget怎么用?PHP Cache::forget使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Cache
的用法示例。
在下文中一共展示了Cache::forget方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testRemove
public function testRemove()
{
$this->cache->set("foo", "bar");
$this->assertEquals("bar", $this->cache->get("foo"));
$this->cache->forget("foo");
$this->assertNull($this->cache->get("foo"));
}
示例2: removeCache
/**
* Removes Cache for given entity
* @param null $entity
*/
public function removeCache($entity = null)
{
if ($entity === null) {
$entity = $this->entity;
}
$this->cache->forget('etag-' . $entity);
$this->cache->forget('content-' . $entity);
}
示例3: returnRoutes
public static function returnRoutes($prefix = null)
{
$dics_for_cache = ['projects', 'types'];
foreach ($dics_for_cache as $dic_name) {
## Refresh dics cache
#Cache::forget('dic_' . $dic_name);
$dic_[$dic_name] = Cache::get('dic_' . $dic_name);
if (!$dic_[$dic_name]) {
Cache::forget('dic_' . $dic_name);
$dic_[$dic_name] = Dic::valuesBySlug($dic_name, function ($query) {
$query->orderBy('lft', 'ASC');
}, ['allfields', 'alltextfields'], true, true, true);
#Helper::d($dic_name); Helper::ta($dic_{$dic_name}); #die;
$dic_[$dic_name] = DicLib::loadImages($dic_[$dic_name], ['avatar', 'image', 'logo', 'photo', 'header_img']);
#Helper::d($dic_name); Helper::ta($dic_{$dic_name}); #die;
Cache::add('dic_' . $dic_name, $dic_[$dic_name], self::$global_cache_min);
}
View::share('dic_' . $dic_name, $dic_[$dic_name]);
#Helper::d($dic_name); Helper::ta($dic_{$dic_name});
}
#Helper::tad($dic_{'city'});
#die;
Route::group(array('prefix' => '{lang}'), function () {
Route::any('/project/{slug}', array('as' => 'app.project', 'uses' => __CLASS__ . '@appProject'));
#Route::any('/ajax/send-message', array('as' => 'ajax.send-message', 'uses' => __CLASS__.'@postSendMessage'));
#Route::any('/ajax/some-action', array('as' => 'ajax.some-action', 'uses' => __CLASS__.'@postSomeAction'));
});
Route::group(array(), function () {
#Route::any('/ajax/send-message', array('as' => 'ajax.send-message', 'uses' => __CLASS__.'@postSendMessage'));
#Route::any('/ajax/some-action', array('as' => 'ajax.some-action', 'uses' => __CLASS__.'@postSomeAction'));
});
}
示例4: generateSitemap
public static function generateSitemap($reGenerate = false)
{
// create new sitemap object
$sitemap = App::make("sitemap");
$sitemap->setCache('laravel.sitemap', 3600);
if ($reGenerate) {
Cache::forget($sitemap->model->getCacheKey());
}
// check if there is cached sitemap and build new only if is not
if (!$sitemap->isCached()) {
// add item to the sitemap (url, date, priority, freq)
$sitemap->add(URL::to('/'), null, '1.0', 'daily');
$categories = Category::get();
foreach ($categories as $category) {
$sitemap->add(URL::route('category', [$category->slug]), null, '1.0', 'daily');
}
// get all lists from db
$lists = ViralList::orderBy('created_at', 'desc')->get();
// add every post to the sitemap
foreach ($lists as $list) {
$sitemap->add(ListHelpers::viewListUrl($list), $list->updated_at, '1.0', 'monthly');
}
}
// show your sitemap (options: 'xml' (default), 'html', 'txt', 'ror-rss', 'ror-rdf')
return $sitemap->render('xml');
}
示例5: get_logout
public function get_logout()
{
$user_id = Auth::user()->id;
Cache::forget($user_id . 'modules');
Auth::logout();
return Redirect::to_action('users@login');
}
示例6: clearAttributeCache
protected static function clearAttributeCache($model)
{
foreach ($model->appends as $attribute) {
$cacheItem = get_class($model) . $model->id . $attribute;
\Cache::forget($cacheItem);
}
}
示例7: update
public function update($model, $input)
{
if ($this->cacheEnabled) {
\Cache::forget($this->getLocaleCacheKey($model->locale));
}
parent::update($model, $input);
}
示例8: update
public function update()
{
define('STDIN', fopen("php://stdin", "r"));
Artisan::call("paperwork:update", ['--quiet' => true]);
Cache::forget('paperwork.commitInfo');
return PaperworkHelpers::apiResponse(PaperworkHelpers::STATUS_SUCCESS, array());
}
示例9: boot
public function boot()
{
$postRepository = $this->app->make('App\\Repositories\\PostRepository');
$this->app['events']->listen('user.avatar', function ($user, $image) use($postRepository) {
if ($user->fully_started) {
$postRepository->add(['content_type' => 'auto-post', 'type_content' => ['type' => 'change-avatar', 'avatar' => $image], 'privacy' => 1, 'type' => 'user-timeline']);
}
});
$this->app['events']->listen('add-album-photos', function ($id, $photos) use($postRepository) {
$albumRepository = $this->app->make('App\\Repositories\\PhotoAlbumRepository');
$album = $albumRepository->get($id);
$postRepository->add(['content_type' => 'auto-post', 'type_content' => ['type' => 'add-photos', 'photos' => $photos, 'photo-count' => count($photos), 'album' => $album], 'privacy' => 1, 'type' => 'user-timeline']);
});
$this->app['events']->listen('like.add', function ($userid, $type, $typeId) use($postRepository) {
if ($type == 'page') {
if (\Auth::check()) {
$page = app('App\\Repositories\\EventRepository')->get($typeId);
$postRepository->add(['content_type' => 'auto-post', 'type_content' => ['type' => 'like-page', 'page' => $page], 'privacy' => 1, 'type' => 'user-timeline', 'auto_like_id' => 'page-' . $page->id]);
\Cache::forget('page-suggestions-' . \Auth::user()->id);
}
} elseif ($type == 'post') {
$post = $postRepository->findById($typeId);
$post->touch();
//method to update this post
\Cache::forget('post-' . $post->id);
}
});
}
示例10: cache
/**
* Caches a model
*
* @param string $model The name of the model
* @param string $keyPart The key to use to cache the model (e.g. primary key)
* @param \App\LaravelRestCms\BaseModel $data The model instance
* @return string
*/
public static function cache($model, $keyPart, $data)
{
$key = static::getCacheKey($model, $keyPart);
\Cache::forget($key);
\Cache::put($key, $data, static::$cacheTime);
return $model;
}
示例11: save
public function save($id, $request)
{
$notifications = $request->get('notifications');
foreach ($notifications as $notification) {
if ($notification['id']) {
$model = $this->model->find($notification['id']);
if (isset($notification['remove'])) {
$model->delete();
continue;
}
$model->type = $notification['type'];
$model->data = $notification['data'];
$model->time = $notification['time'];
$model->msg = $notification['msg'];
$model->save();
} else {
if (isset($notification['remove'])) {
continue;
}
$data = $notification + ['channel_id' => $id];
$this->model->create($data);
}
}
$key = \Config::get('site.cacheChannelsWithNotifications');
\Cache::forget($key);
}
示例12: onDeleteRowResponse
public function onDeleteRowResponse(array &$response)
{
$this->removeTemplate($response['values']['ident']);
$def = $this->controller->getDefinition();
EventsBackend::log(array('ident' => $def['db']['table'] . '_delete', 'object_table' => $def['db']['table'], 'object_id' => Input::get('id')));
Cache::forget('settings');
}
示例13: set
/**
* Store setting
*
* @param $key
* @param $value
* @return bool
*/
public function set($key, $value)
{
/**
* Setup cache key
*/
$cacheKey = 'setting_' . md5($key);
/**
* Fetch from database
*/
$setting = Setting::where('key', '=', $key)->first();
/**
* If nothing was found, create a new object
*/
if (!is_object($setting)) {
$setting = new Setting();
}
/**
* Set the values
*/
$setting->setKey($key)->setValue($value)->save();
/**
* Expire the cache
*/
\Cache::forget($cacheKey);
return true;
}
示例14: clearSession
/**
* Clear user data in session.
*/
function clearSession()
{
\Cache::forget(session()->pull('PHPSESSID'));
session()->forget('COOKIE');
session()->forget('courseLists');
session()->forget('courseListsContent');
}
示例15: Check_User_Cart
function Check_User_Cart()
{
$Identifier = '';
if (!Sentry::check()) {
return false;
} else {
$Identifier = Sentry::user()->id;
if (Cookie::has('Anon_Cart_Extension')) {
$AnonIdentifier = Cookie::get('Anon_Cart_Extension');
$dataAnon = Cache::get('user_cart.' . $AnonIdentifier);
if (Cache::has('user_cart.' . $Identifier)) {
$dataUser = Cache::get('user_cart.' . $Identifier);
if ($dataAnon != null && $dataUser != null) {
foreach ($dataAnon as $key => $value) {
if (!isset($dataUser[$key])) {
$dataUser[$key] = $value;
}
}
Cache::forever('user_cart.' . $Identifier, $dataUser);
Cache::forget('user_cart.' . $AnonIdentifier);
}
} else {
if ($dataAnon != null) {
Cache::forever('user_cart.' . $Identifier, $dataAnon);
Cache::forget('user_cart.' . $AnonIdentifier);
}
}
}
}
}