Active
Project:
Cache Router
Version:
6.x-1.x-dev
Component:
Code
Priority:
Normal
Category:
Feature request
Assigned:
Unassigned
Reporter:
Created:
29 Dec 2009 at 19:05 UTC
Updated:
29 Jan 2010 at 11:43 UTC
To use memcache functions that are not implemented in Cacherouter (e.g. "add") I had to reimplement Cacherouter's __init function, because it's private and I can't call it directly outside. It seems to be only way of accessing cacherouter's memcache object, if I don't subclass Cacherouter's classes (I don't want to).
Please correct me if I'm wrong. I'm not good at OOP.
Comments
Comment #1
crea commentedI.e. I have this:
Note how Memcache API has dmemcache_object() function that makes it very simple, and for Cacherouter there's lot of code needed, with code duplication. I would prefer to use single function just as in Memcache API.
This will be even bigger issue for Memcached engine because PECL Memcached module has even more advanced functions ("cas" etc).
Comment #2
andypostDo you really need direct access to engine object?
Comment #3
crea commentedOfcourse I don't need engine object access. I'm only using it to initialize and access Memcache object. That's lot of repeating code needed to reuse Memcache object of CacheRouter.
Comment #4
andypostMemcache object is a part of $GLOBALS['cache']->map array and one per bin - take a look inside Cacherouter.php
Name "cache" is bad for global object and engine class name and should be changed at #564460: Class conflict, namespace collisions
Comment #5
crea commentedDid you read my code above ? Yes, I use global cache variable, but that's not guaranteed to work, cause cache can be uninitialized. So to initialize it I repeat CacheRouter's code in my cacherouter_init() function. Please try to read carefully. Thanks.