I am trying to run simple code of cache using memcache in my laravel project.
I have added CACHE_DRIVER=memcached
in my .env file.
I have created folder of memcache in C drive and added a file memcache.exe in that, and run in cmd by opening it as administrator.
my code in route is:
Route::get('/', function () {
// return view('welcome');
Cache::put('k1','created memcached memory!!',1);
Cache::add('k2','used "add" in memcached!!',2);
Cache::forever('k3','using forever to create cache',3);
$k1 = Cache::get('k1','default');
$k2 = Cache::pull('k2','default');
$k3 = Cache::pull('k3','default');
Cache::forget('k1');
$check = 0;
if(Cache::has('k1')){
return $check = 1;
}
});
when I run this route, i get error as
Class 'Memcached' not found
Is there any solution?
EDIT:
When i remove CACHE_DRIVER=memcached
and use CACHE_DRIVER=file
above code runs fine. What is correct way CACHE_DRIVER=memcached
or CACHE_DRIVER=file
? I had referred that from video 1