Hello!
I started using Zend_Cache for my community project to save a lot of database results which can change more or less frequently, depending on the activities of the user.
The setup for the cache is like this:
PHP Code:
$backend_options = array('cache_dir' => '_zend_cache/collections/');
$frontend_options = array('lifetime' => null, 'automatic_serialization' => true);
$cache_result = Zend_Cache::factory('Core', 'File', $frontend_options, $backend_options);
Since I need more than one result cached per user I tagged the caches with the user-id like this:
PHP Code:
$cache_result->save($result1, $cache_id_1, array($user_id));
$cache_result->save($result2, $cache_id_2, array($user_id));
$cache_result->save($result3, $cache_id_3, array($user_id));
If the user does some updates in his profiles I simply delete his caches like this:
PHP Code:
$cache_result->clean(Zend_Cache::CLEANING_MODE_MATCHING_TAG, array((string)$user_id));
But this is a heavy performance killer! I was wondering why functions which were more or less fast in the past are now real sleepers so I started logging the process and the result was this:
Quote:
11.03.2008 22:00:37 - Start
-------------------------------------------------
11.03.2008 22:00:37 - SET AUTOCOMMIT = 0
-------------------------------------------------
11.03.2008 22:00:37 - INSERT INTO table...
-------------------------------------------------
11.03.2008 22:00:37 - UPDATE user_counts...
-------------------------------------------------
11.03.2008 22:00:37 - Reading some information...
-------------------------------------------------
11.03.2008 22:00:38 - COMMIT
-------------------------------------------------
11.03.2008 22:02:19 - Cache finally deleted.
-------------------------------------------------
|
As you can see removing the cache took almost 2 minutes! And the users are waiting that something happens on the site!
Is there some bug in the zend framework or do I have to make another setup for the cache? Or any other ideas how the performance of the zend cache can be improved?
Greetings
Carsten