How to cache query result in slim?


#1

Hi

I want to cache frequently used queries and send them back without calling database.
I am using eloquent with slim framework.

Please guide me how to do it


#2

Hi!

I haven’t tested it myself yet, but maybe that could be a solution:

Rememberable, Laravel 5 query cache


#3

Can i implement memcached in slimframework? Please give me some guide for this.


#4

Can i implement memcached in slimframework?

Yes. You just need the memcached PHP extension:
http://php.net/manual/en/book.memcached.php
http://php.net/manual/en/memcached.installation.php

Just add a new entry to your container:

$container['memcached'] = function (Container $container) {
    $mc = new Memcached(); 
    $mc->addServer("127.0.0.1", 11211);
    return $mc;
}

Usage

$mc = $container->get('memcached');
$mc->set("foo", "Hello!"); 
$mc->set("bar", "Memcached...");