Category : caching

here I’m trying to store key $code = mt_rand(111111, 999999); Cache::put(‘notification’, $code, 600); and in another function I try to get that key in this way if (Cache::has(‘notification’) and Cache::get(‘notification’) == $request->code) return response()->json([‘status’ => true, ‘group’ => $request->res[‘group’]]); else return response()->json([‘status’ => false, ‘message’ => ‘کد اشتباه است’]); but it always return false Source: ..

Read more

guys! I have a simple route: example.com/dev that call a controller with Atomic Lock code. While first request executing this code, the second request should wait a time if lock exists, but it working depending on web browser. Code in controller: $a = []; $time = time(); $lock = Cache::lock(‘foo’, 60); try { $lock->block(20); $a[‘start’] ..

Read more

I have an existing application with a ton of cache files written using the Laravel file driver. These follow a specific directory and naming structure (e.g): cache/data/ 2d/ 6e/ 2d6eece558d9143286c4a08bb5757bb2cb6e9h9kf And if it has an expiry, the first 10 chars of the file is the expiry timestamp in unix time. 1605235030a:3:{s:3:"price";s:6:"342.99"…… I want to migrate ..

Read more

Can anyone help me? I use cache. But I see same results on every pages when I use pagination. How can I fix it? Thanks in advance for create,updated,edit, saved i use laravel Model Observer. My PostController public function allpost(Request $request) { if($request->cache ==’flush’) { Cache::flush(); } $data =[]; $posts =Cache::get(‘posts’,[]); if(empty($posts)) { $posts = ..

Read more

I am not getting any errors but I am trying to simply use the laravel file cache. I have this at the top: use IlluminateSupportFacadesCache; And I just have some code: //set the cache if (Cache::has(‘is_reporting’)) { //key exists assign value Cache::put(‘is_reporting’, $reporting_cache_value, 20); } else{ //key does not exist Cache::add(‘is_reporting’, $reporting_cache_value, 20); } No ..

Read more

Lumen Version: 8.0.0 PHP Version: 7.4.9 Description: I can’t put cache.Files driver does not work. Boostrap/app.php $app->withFacades(); $app->withEloquent(); $app->configure(‘app’); $app->register(IlluminateRedisRedisServiceProvider::class); $app->configure(‘database’); $app->configure(‘cache’); return $app; Config/Cache.php return [ ‘default’ => env(‘CACHE_DRIVER’, ‘file’), ‘stores’ => [ // … ‘file’ => [ ‘driver’ => ‘file’, ‘path’ => storage_path(‘framework/cache/data’), ], // … ], ‘prefix’ => env( ‘CACHE_PREFIX’, Str::slug(env(‘APP_NAME’, ‘lumen’), ..

Read more

Thank you in advance I have deployed the project over google cloud APP ENGINE, seems everything working Generally laravel stores cached file and sessions file at /storage/framework/cache and /storage/framework/sessions, but for google cloud, we use app.yaml file for the configuration (Seems same as .env), so in app.yaml looks like below runtime: php env: flex runtime_config: ..

Read more

I’m using Laravel 8 / Homestead / Redis. I am trying to use cache in my APIs, but having trouble. When using tinker, I can do: >>> $token = Cache::rememberForever(‘nova_api_token3’, function () use ($credentials) { $response = IlluminateSupportFacadesHttp::asForm() ->withHeaders(["Content-Type" => "application/x-www-form-urlencoded"]) ->withBasicAuth($credentials->nova_id, $credentials->nova_secret) ->post(config(‘nova-enedis.url’) . "/v1/oauth2/token", [ "grant_type" => "client_credentials" ]); $body = json_decode($response->body()); return ..

Read more

I’m trying to get a token from external API. Token lasts 1h, so I would like to put it in cache with a duration of 1 hour. $seconds = 60*60; $token = Cache::remember(‘nova_api_token’, $seconds, function () use ($request, $credentials) { try { $response = Http::asForm() ->withHeaders(["Content-Type" => "application/x-www-form-urlencoded"]) ->withBasicAuth($credentials->nova_id, $credentials->nova_secret) ->post(config(‘nova.url’) . "/v1/oauth2/token", [ "grant_type" ..

Read more

I have Laravel 7.28.* project working in my Windows 10 64Bit OS, which is inside the master branch of the Git repository. Now when I run the command php artisan optimize it always ends up with this error, exactly when it runs php artisan route:cache command: [2020-10-13 11:46:06] local.ERROR: Unable to prepare route [logout] for ..

Read more

laravel : 7.28.0 "php": "^7.2.5" When I enter any link it gives the following errors: SymfonyComponentHttpKernelExceptionNotFoundHttpException in /home/mick/vendor/laravel/framework/src/Illuminate/Foundation/Application.php:1064 and SymfonyComponentHttpKernelExceptionNotFoundHttpException in /home/mick/vendor/laravel/framework/src/Illuminate/Routing/AbstractRouteCollection.php:43 route files api.php -> Empty web.php Route::get(‘/’, ‘[email protected]’)->name(‘home’); Route::get(‘/clear’, ‘[email protected]’)->name(‘clear_cache’); Route::get(‘/installations’, ‘[email protected]’)->name(‘installations’); Route::get(‘/installations/step/2’, ‘[email protected]’)->name(‘installations_step_two’); Route::post(‘/installations/step/2’, ‘[email protected]’); Route::get(‘/installations/step/final’, ‘[email protected]’)->name(‘installation_final’); /** * Authentication */ Route::get(‘/login’, ‘[email protected]’)->name(‘login’)->middleware(‘guest’); Route::post(‘/login’, ‘[email protected]’); Route::any(‘/logout’, ‘[email protected]’)->name(‘logout’); Route::get(‘/register’, ‘[email protected]’)->name(‘register’)->middleware(‘guest’); Route::post(‘/register’, ‘[email protected]’); Route::get(‘/forgot-password’, ..

Read more

I’ve deploy a laravel API some months ago into a shared hosting (banahosting). It’s been working fine until yesterday that all API endpoints returns an error: IlluminateDatabaseQueryException: SQLSTATE[HY000] [1045] Access denied for user ‘####’@’localhost’ (using password: YES) (SQL: select `destinations`.*, (select count(*) from `experiences` where `destinations`.`id` = `experiences`.`destination_id`) as `experiences_count` from `destinations` order by `id` ..

Read more