KoolReport's Forum

Official Support Area, Q&As, Discussions, Suggestions and Bug reports.
Forum's Guidelines

Memcache #3267

Open eMaX opened this topic on on Mar 18 - 1 comments

eMaX commented on Mar 18

Hi Team,

I've a question regarding memcache.

I'm following the instructions here, and I do know that I have memcached working correctly as I use it also for my own queries. I want to also use it for queries that I pass on to datatables. So basically, I have this:

$this->ds = new \koolreport\datasources\PdoDataSource(...);

later...

$this->ds->query($query)->params($params)

which I pass on to

DataTables::create(array(
...
 "dataSource"     => function () {
                    return $this->ds->query($query)->params($params);
  },

Now it works all well, but it does not use the cache.

I'd actually even rather like to just pass on a result set to my datatables content, but my understanding is that I'd then have to also implement serverside myself. Like I've a number of graphs that I display too, and their data is fetched from the database and then cached. That works fine.

When I experiment with the cache in the report, so here...

use \koolreport\cache\MemCache;

class MyReport extends KoolReport
{
    function cacheSettings()
    {
        return array(
            "ttl"=>60,
            "servers"=>array(
                "localhost"=>11211,
            )
        );
    }

and e.g. I don't put the right port, nothing apparently happens. So it's not even trying to use it.

Any idea how to use a datatable with the cache?

Thanks!

Sebastian Morales commented on Mar 20

Pls try to use MemCache as a trait inside your report class like this:

class MyReport extends \koolreport\KoolReport
{
    use \koolreport\cache\MemCache; // add this trait use here instead of outside the class

Let us know how this works for you.

Build Your Excellent Data Report

Let KoolReport help you to make great reports. It's free & open-source released under MIT license.

Download KoolReport View demo
None yet

None