1
hervet
PersistableObjectHandler with Cache
  • 2007/10/12 18:06

  • hervet

  • Friend of XOOPS

  • Posts: 2267

  • Since: 2003/11/4


In some of my modules, I'm using a modified version of Mithrandir's PersistableObjectHandler.

This version brings some news methods to the class but it is also capable to use cache (based on files)

With its cache, you can reduce your MySQL queries by 100% in your modules.

This cache script is coming from PEAR and the whole "system" (the PersistableObjectHandler class + the cache
system) in only compatible with Php 5.

To store the cached files, the class uses a sub folder of the XOOPS upload folder (you have to create it, the
class does not do it for you)

I choose to use an unlimited cache life time.
The WHOLE cache is removed when the PersistableObjectHandler class is doing an insert, update or delete.

Each sql query's result is stored in a unique file who's name is the md5 of the query (with the "start" and "limit")
You can change this name in the _getIdForCache method.

Data are automatically serialized by the Cache class and are also automatically unserialized by it.

The cache parameters are located and can be changed in the class constructor.

You can download this code here
and you can read the cache manual here.

If someone, a developer, have some new ideas to bring on this subject, please share.

2
Catzwolf
Re: PersistableObjectHandler with Cache
  • 2007/10/12 18:22

  • Catzwolf

  • Home away from home

  • Posts: 1392

  • Since: 2007/9/30


Hey Herve,

I use this object class within my own modules now (And Zarilia) and I was actually starting to look at query caching using MySQL 5 (As this function is built in) but I really do like the look of this and will give it a try later on tonight.

A forward thinking approach.

Nice one,

Catz

3
Predator
Re: PersistableObjectHandler with Cache
  • 2007/10/12 18:27

  • Predator

  • Just popping in

  • Posts: 35

  • Since: 2005/5/20


Hi Herve,

thanks for sharing nice feature indeed ;) currently I'm installing all available Stuff to check how all works I see some nice improvements but sadly on different places like the XOOPS 2.0.18 XT-XM which is really interesting.
Predator

- Time is a created thing. To say, "I don't have time" is like saying "I don't want to."
- Lao-Tzu......

4
Catzwolf
Re: PersistableObjectHandler with Cache
  • 2007/10/12 18:38

  • Catzwolf

  • Home away from home

  • Posts: 1392

  • Since: 2007/9/30


It's a shame that dev.xoops.org is not really used anymore, it would be a nice place to get core/module development discussions started again.

anyway, will give some feedback later :)

5
Anonymous
Re: PersistableObjectHandler with Cache
  • 2007/10/12 18:38

  • Anonymous

  • Posts: 0

  • Since:


I wish I knew what you guys were talking about

Keep talking - don't mind me

6
Predator
Re: PersistableObjectHandler with Cache
  • 2007/10/12 18:43

  • Predator

  • Just popping in

  • Posts: 35

  • Since: 2005/5/20


Quote:

catzwolf_ wrote:
It's a shame that dev.xoops.org is not really used anymore, it would be a nice place to get core/module development discussions started again.

anyway, will give some feedback later :)


Well the xoopsforge modules need a lot work to be back uptodate, will rethink this i guess i still have a more improved version somewhere
Predator

- Time is a created thing. To say, "I don't have time" is like saying "I don't want to."
- Lao-Tzu......

7
Catzwolf
Re: PersistableObjectHandler with Cache
  • 2007/10/12 18:47

  • Catzwolf

  • Home away from home

  • Posts: 1392

  • Since: 2007/9/30


Ok, what is he talking about, we don't have a clue either, we just humouring him at the moment ;)

Actually, what he is proposing is a way of reducing the amount of MySQL queries used by XOOPS or the modules that use this method of dealing with queries.

What the script does is reduce the stress on a database server by caching a query on disk and if a module of core accesses the database with the same query, rather than using the database, the cache is used instead. Thus reducing the amount of work the server has to do.

This should be added to the core when the merge between 2. And 2.2 are done. Hopefully we shall the PersistableObjectHandler as part of the database framework. Makes life a lot easier and modules/core a lot safer.

Very Very good thing indeed.

8
Predator
Re: PersistableObjectHandler with Cache
  • 2007/10/12 18:47

  • Predator

  • Just popping in

  • Posts: 35

  • Since: 2005/5/20


We also use the Casche_Lite class on the Joomla! 1.0.x series without the need of PEAR so also working for PHP4 and not only PHP5 ;) , will give it a try and bring some feedback later this weekend.
Predator

- Time is a created thing. To say, "I don't have time" is like saying "I don't want to."
- Lao-Tzu......

9
Catzwolf
Re: PersistableObjectHandler with Cache
  • 2007/10/12 18:49

  • Catzwolf

  • Home away from home

  • Posts: 1392

  • Since: 2007/9/30


I actually did look at this as well Pred, but I wasn't sure how joomla would have felt about me using it lol

10
wizanda
Re: PersistableObjectHandler with Cache
  • 2007/10/12 18:59

  • wizanda

  • Home away from home

  • Posts: 1585

  • Since: 2004/3/21


Web dev x =

Login

Who's Online

162 user(s) are online (100 user(s) are browsing Support Forums)


Members: 0


Guests: 162


more...

Donat-O-Meter

Stats
Goal: $100.00
Due Date: Apr 30
Gross Amount: $0.00
Net Balance: $0.00
Left to go: $100.00
Make donations with PayPal!

Latest GitHub Commits