How to cache query result in slim?

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

Hi!

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

Rememberable, Laravel 5 query cache

Edit / Note: Rememberable interfaces directly with Laravel and depends on the app() function provided by it. The developer has no plans to support use outside of Laravel.

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

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...");
1 Like

@mahesh have you found a solution,.?