本文整理汇总了PHP中Cache::pull方法的典型用法代码示例。如果您正苦于以下问题:PHP Cache::pull方法的具体用法?PHP Cache::pull怎么用?PHP Cache::pull使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Cache
的用法示例。
在下文中一共展示了Cache::pull方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: setupDb
/**
* Sets up db by running migration and seeder.
*
* @return \Illuminate\Http\RedirectResponse
*/
public function setupDb()
{
if (\Cache::get('setup_db', false)) {
$request = \Request::instance();
$method = $request->method();
if (Verbs::GET === $method) {
return view('setup', ['version' => config('df.version')]);
} else {
if (Verbs::POST === $method) {
try {
if (\Cache::pull('setup_db', false)) {
\Artisan::call('migrate', ['--force' => true]);
\Artisan::call('db:seed', ['--force' => true]);
if ($request->ajax()) {
return json_encode(['success' => true, 'redirect_path' => '/setup']);
} else {
return redirect()->to('/setup');
}
} else {
if ($request->ajax()) {
return json_encode(['success' => false, 'message' => 'Setup not required. System is already setup']);
}
}
} catch (\Exception $e) {
if ($request->ajax()) {
return json_encode(['success' => false, 'message' => $e->getMessage()]);
} else {
return view('errors.generic', ['error' => $e->getMessage(), 'version' => config('df.version')]);
}
}
}
}
}
return redirect()->to('/');
}
示例2: hasInvalidState
/**
* {@inheritdoc}
*/
protected function hasInvalidState()
{
if ($this->isStateless()) {
return false;
}
$urlState = $this->request->input('state');
$cacheState = \Cache::pull($urlState);
return !(strlen($cacheState) > 0 && $urlState === $cacheState);
}
示例3: getToken
/**
* Get the token credentials for the request.
*
* @return \League\OAuth1\Client\Credentials\TokenCredentials
*/
protected function getToken()
{
$temp = null;
if ($this->usesState()) {
$temp = $this->request->getSession()->get('oauth.temp');
} else {
$key = $this->request->get('oauth_token');
$temp = \Cache::pull($key);
}
return $this->server->getTokenCredentials($temp, $this->request->get('oauth_token'), $this->request->get('oauth_verifier'));
}
示例4: fire
/**
* Execute the console command.
*
* @return void
*/
public function fire()
{
echo 'Iniciado' . PHP_EOL;
$start = microtime(true);
$cacheKey = md5(uniqid(''));
$totalUsers = User::count();
$pid = pcntl_fork();
if ($pid == -1) {
die('could not fork =(');
} else {
if ($pid) {
// we are the parent
//É necessário reconectar no banco, os processos vão compartilhar
//a conexão, o que irá gerar erro
\DB::reconnect('mysql');
//Pega os usuários da primeira metade do total
$users = $this->getUsers($totalUsers / 2, 0);
//Aguarda o processo filho terminar
pcntl_wait($status);
//Faz um merge do que o processo pai e filho processaram
//Os dados do processo filho estão no cache
$users = array_merge($users, \Cache::pull($cacheKey));
} else {
// we are the child
//É necessário reconectar no banco, os processos vão compartilhar
//a conexão, o que irá gerar erro
\DB::reconnect('mysql');
//Pega os usuários da segunda metade do total
$users = $this->getUsers($totalUsers / 2, $totalUsers / 2);
//Armazena os usuários processados no cache
\Cache::forever($cacheKey, $users);
die;
}
}
echo 'Processados ' . count($users) . ' usuários' . PHP_EOL;
echo 'Demorou ' . number_format((microtime(true) - $start) * 1000, 2, ',', '') . 'ms' . PHP_EOL;
}
示例5: removeCache
/**
* 清除缓存
* @param string $cachename
* @return boolean
*/
public static function removeCache($cachename)
{
//TODO: remove cache implementation
return \Cache::pull($cachename);
}
示例6: getToken
/**
* {@inheritdoc}
*/
protected function getToken()
{
$key = $this->request->get('oauth_token');
$temp = \Cache::pull($key);
return $this->server->getTokenCredentials($temp, $this->request->get('oauth_token'), $this->request->get('oauth_verifier'));
}
示例7: testMakeLoginToken
public function testMakeLoginToken()
{
$user = $this->createUser();
$token = $user->makeLoginToken($user->user_id);
$id = Cache::pull('login_token_' . $token);
$this->assertEquals($id, $user->user_id);
}
示例8:
<a href="http://github.com/atrauzzi/laravel-drydock">Github</a>
@if($lastCronRun)
<div class="notice">Last cron run {{ $lastCronRun }} (runs every minute)</div>
@endif
<hr />
<input type="email" id="email" placeholder="Enter an email address..." />
<input type="text" id="message" placeholder="Enter a message..." />
<a href="javascript:void(0)" onclick="location.href='/dev/queue/test?message=' + message.value + '&email=' + email.value; message.value=''; email.value='';">Queue it!</a>
<br />
<?php
$message = Cache::pull('last-message');
?>
<div id="last-message">
@if($message)
<div>
<h4>Your message is done processing!</h4>
<div class="notice">{{ $message }}</div>
</div>
@endif
</div>
</div>
</div>
</body>
</html>
示例9: function
Route::post('activate/FirstLink', ['as' => '1stlinkactivation', 'uses' => 'CodeController@activateFirstLink']);
// after first link is activated dont show anymore this url to them
Route::post('signup', ['as' => 'signup', 'uses' => 'Auth\\AuthController@create']);
// Route::get('{link?}', ['as' => 'links', 'uses' => 'LinkController@getRefLink']);
Route::get('activeSponsor/{id}', function ($id) {
$id = App\Link::where('id', $id)->firstOrFail()->activeSponsor($id);
return $id;
});
// Route::get('code/all', ['as' => 'codeall', 'uses' => 'CodeController@index']);
Route::get('code/{linkID}/{PINCODE}', ['as' => 'code', 'uses' => 'CodeController@attachLink']);
// Update user account data
// Route::put('profile', ['as' => 'profile/update', 'uses' => 'UserController@update']); // Not working yet
Route::get('/vue', function () {
return view('vue');
});
Route::get('api/users', function () {
$value = Cache::rememberForever('users', function () {
return \App\Profile::latest()->take(50)->select('display_name', 'created_at')->get();
// Should Only Fetch the Users Display Name!
});
return $value = Cache::pull('users');
});
//Route::post('api/users', function(){
// App\User::create(Request::all());
//});
//
Route::get('getCookie', function () {
return view('welcome');
});
//Route::get('/activate/{code}', 'Auth\AuthController@activateAccount
Route::get('{link?}', ['as' => 'reflink', 'uses' => 'LinkController@showRefLink']);
示例10: getActivation
/**
* Actiovation account
*/
public function getActivation($code = null)
{
if (Session::get('activated')) {
return View::make(Config::get('larauth::views.activation'));
}
if (Input::get('code')) {
$code = Input::get('code');
}
if ($code) {
try {
$user = Sentry::findUserByActivationCode($code);
$user->attemptActivation($code);
// добавляем пользователя в группы
foreach (Config::get('larauth::append_groups') as $group) {
try {
$oGroup = Sentry::findGroupByName($group);
} catch (\Cartalyst\Sentry\Groups\GroupNotFoundException $e) {
Log::alert("Попытка добавдения пользователя :user_email в несуществующую группу :group", ['user_email' => $user->email, 'group' => $group]);
}
$user->addGroup($oGroup);
}
$data = ['email' => $user->email, 'password' => Cache::pull(md5($user->email)), 'subject' => trans('larauth::larauth.registration_success')];
$this->sendMail(Config::get('larauth::views.mail_registration'), $data);
return Redirect::route('larauth.activation')->with('activated', TRUE);
} catch (Cartalyst\Sentry\Users\UserNotFoundException $e) {
return Redirect::route('larauth.activation')->with('error', trans('larauth::larauth.wrong_activation_code'));
}
}
return View::make(Config::get('larauth::views.activation'), ['error' => Session::get('error'), 'code' => $code]);
}
示例11: function
/*
|--------------------------------------------------------------------------
| Application Routes
|--------------------------------------------------------------------------
|
| This route group applies the "web" middleware group to every route
| it contains. The "web" middleware group is defined in your HTTP
| kernel and includes session state, CSRF protection, and more.
|
*/
$route->group(['middleware' => ['web']], function (Router $route) {
$route->get('/', function () {
$lastCronRun = new \Carbon\Carbon(Cache::get('last-cron'));
$lastCronRun = $lastCronRun->diffForHumans();
return view('welcome', compact('lastCronRun'));
});
$route->get('/dev/info', function () {
ob_start();
phpinfo();
$phpinfo = ob_get_contents();
ob_end_clean();
return new Response($phpinfo);
});
$route->get('/dev/queue/test', function (Request $request) {
dispatch(new TestJob($request->get('message'), $request->get('email')));
return new Response(null, 204);
});
$route->get('/api/web/last-message', function (Request $request) {
return new JsonResponse(Cache::pull('last-message'));
});
});
示例12: function
/*
* Main page
*/
Route::filter('dashboardFilter', function () {
if (!Schema::hasTable('users')) {
return Redirect::to('start');
}
if (!User::all()->count()) {
return Redirect::to('register');
}
if (!Auth::check()) {
return Redirect::to('login');
}
});
Route::get('/', array('before' => array('dashboardFilter', 'nexmo'), function () {
return View::make('hello', array('credit_balance' => Cache::pull('nexmo'), 'numbers' => Number::all()));
}));
/*
* Login page
*/
Route::filter('loginFilter', function () {
if (!Schema::hasTable('users')) {
return Redirect::to('start');
}
if (!User::all()->count()) {
return Redirect::to('register');
}
});
Route::get('/login', array('before' => array('loginFilter', 'nexmo'), 'as' => 'login', function () {
return View::make('login');
}));