I am making an simple larvel application to show memcached use. The Os i am using is ubuntu. The records in the database are 50k.
I successfully installed memcache and saved data in it but the problem is that when i am retrieving data from memcache its taking too long same as a retrival from database would. Kindly let me know what is the issue. I have installed memcache on windows as well but the issue is same on windows as well.
/**
* Created by PhpStorm.
* User: Delll
* Date: 14-Sep-18
* Time: 2:44 AM
*/
namespace App\Http\Controllers;
use App\User;
use Illuminate\Http\Request;
use App\Http\Requests;
use App\Http\Controllers\Controller;
use Illuminate\Support\Facades\Cache;
use Illuminate\Support\Facades\DB;
class User_controller extends Controller{
public function index(){
$memcache = 'Using memcache';
$users = Cache::remember("key",6999,function(){
return DB::table('users')->get();
});
// Cache::pull('key');
$val= Cache::has('key');
if($val !=null){
echo "Found ".$val;
}else{
echo "Not Found ".$val;
}
return view('pages.home',compact('users','memcache'));
}
public function remove(){
$value = Cache::pull('key');
return $value;
}
}
The result from memcache should be retrieved faster than database.