JCacheStorageDb for storing cache files in database

Locked
User avatar
Geraint
Joomla! Guru
Joomla! Guru
Posts: 561
Joined: Fri Aug 19, 2005 5:23 pm
Location: Gogledd Cymru

JCacheStorageDb for storing cache files in database

Post by Geraint » Thu Aug 14, 2008 4:15 pm

I have implemented a database based cache storage handler (see attached zip file). The reasons for considering a db based caching solution are as follows:
  • Checking the expire value for cache files requires an extra file read for every get from a file cache
  • Garbage collection for JCacheStorageFile can be very slow if you have lots of files
  • With a database its a single query to garbage clean which is about as efficient as it gets with the right indexes
A few notes about my solution:
  • The first thing a cache instance does is a garbage clean
  • If the garbage clean fails with an error code 1146 then the table doesn't exists and its created
My main motivation for writing this was that I have a component where many of the IDs are not reused often enough to ensure that the files were cleaned. As a result the cache files started to grow excessively large. I then tried implementing a call to gc() from an onAfterRender plugin handler but discovered that this can be painfully slow if you have a few thousand cache files.

Feedback and thoughts gratefulyl received.

Geraint

p.s. If DB space is an issue we could also consider a hybrid cache system where the expiry and group information are stored in the DB but the data stores in files.
You do not have the required permissions to view the files attached to this post.

User avatar
Geraint
Joomla! Guru
Joomla! Guru
Posts: 561
Joined: Fri Aug 19, 2005 5:23 pm
Location: Gogledd Cymru

Re: JCacheStorageDb for storing cache files in database

Post by Geraint » Tue Sep 09, 2008 2:34 pm

Is there any interest in this concept at all or shall I package it as a 3rs party extension?


Locked

Return to “Feature Requests - White Papers - Archived”