Welcome Guest, Not a member yet? Register   Sign In
MP_Cache: Simple flexible Partial Caching
#31

[eluser]sn4k3[/eluser]
how many good that library is with MySQL long queries?

example: 1000 rows, with the following table:

Code:
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `shortname` varchar(30) NOT NULL,
  `name` varchar(255) NOT NULL,
  `shortdescription` text NOT NULL,
  `description` text NOT NULL,
  `img` varchar(255) NOT NULL,
  `realprice` decimal(5,2) unsigned NOT NULL,
  `shipmenttax` decimal(3,2) unsigned NOT NULL,

can PHP handle so much data in a array?
#32

[eluser]Jelmer[/eluser]
I doubt that would be a problem, but why in the world would you want to use 1000 rows on a single page? You'd paginate that query wouldn't you? And if you paginate it you can also cache it paginated.

Also: this isn't meant to replace your DB, your DB will always be more powerfull. It is meant to be used on queries that are needed often and are pretty simple. I expect there's a point where the time needed to retrieve the cache becomes more then the DB query would need, though I would not expect that point to be reached quickly. Your 1000 rows with multiple fields might just reach it (needing multiple megabytes)
#33

[eluser]sn4k3[/eluser]
just a question,

is not for paginate, is just for admin part,
i cache all products table
And only when i create a new product in database, cache will be deleted to update.
So i cache all products to easy show products on a list

but since is large data in future it is a bad idea, also PHP dont support large arrays like that.
#34

[eluser]Jelmer[/eluser]
I didn't mean my answer in a bad way, I was just genuinly surprised you'd want that.
In my opinion a thousand rows is too much for one page, being admin or not. Also I personally don't cache anything in the admin. Caching is for parts of the website that are frequently requested, possibly multiple times per second or even more. Caching the admin isn't worth the trouble in my opinion because those operations are incidental (server-load wise) and only for one or a few users.
And lastly, you can make mistakes implementing Cache. And when you're editing the database (as you probably are in the admin) you should always work on the real data, not the cached data to prevent miscommunications between you and the system.

I must admit I'm not aware on any limitation for the length of an array. You are limited in the amount of memory you're using, which could conceivibly stop you from using such gigantic arrays.
#35

[eluser]sn4k3[/eluser]
ok, i understand.
but would cache improve site?
since it reads and write from an file and after serialize / deserialize it can be slow than use MySQL?
#36

[eluser]mr.crazy[/eluser]
where is the "$this->pages->page"?
#37

[eluser]erik.brannstrom[/eluser]
Thank you for this library! This was exactly what I needed for caching only parts of controller data instead of the whole view. It only took minutes from download to having it successfully implemented on my site.

Good job mate!
#38

[eluser]Jelmer[/eluser]
@mr.crazy

That's not an actual function or model, it's just there as an usage example.
#39

[eluser]Jelmer[/eluser]
I've moved MP_Cache to BitBucket and there's an extra class included that allows usage like below (it's not yet in the user guide but I'll add it shortly):
Code:
$cache = Cache::set('pages/'.$page_id);
$page = $cache->get();
if ($page === FALSE)
{
    // Write the cache
    $cache->set_contents($page)
        ->set_dependencies(array('menus'))
        ->write();
}




Theme © iAndrew 2016 - Forum software by © MyBB