Slightly off the rails ;). Cache_Manager is a repository of cache configurations to assist in lazy-loading caches as needed (rather than instantiating them all up front or piecemeal across the app), so in a sense it works almost like a Registry, albeit one strictly tied to caches.
Pádraic Brady
http://blog.astrumfutura.com
http://www.survivethedeepend.com
OpenID Europe Foundation Irish Representative
From: Ralph Schindler <ralph.schindler@zend.com>
To: sina miandashti <miandashti@gmail.com>; Zend MVC <fw-mvc@lists.zend.com>
Sent: Tue, February 16, 2010 4:27:16 PM
Subject: RE: [fw-mvc] zend_registry or zend_cache_manager
From: Volker Orgeldinger on behalf of sina miandashti
Sent: Tue 2/16/2010 12:45 AM
To: 'Zend MVC'
Subject: [fw-mvc] zend_registry or zend_cache_manager
http://blog.astrumfutura.com
http://www.survivethedeepend.com
OpenID Europe Foundation Irish Representative
From: Ralph Schindler <ralph.schindler@zend.com>
To: sina miandashti <miandashti@gmail.com>; Zend MVC <fw-mvc@lists.zend.com>
Sent: Tue, February 16, 2010 4:27:16 PM
Subject: RE: [fw-mvc] zend_registry or zend_cache_manager
Hmm, I think it's best to back up and talk about the role of a cache vs. the role of a registry.
In PHP, a cache is used to store objects, text, and other stuff that might have been complex, timely, resource intensive or otherwise expensive to generate. It is stored in a fashion such that the cost of generating whatever it was is not incurred on each and every request, but so that the cost is incurred on one request, and the result can be shared across multiple requests. (Remember, PHP is a shared-nothing architecture, objects cannot be shared between requests without some form of serializing-storing-unserializing). That is what Zend_Cache is for.
Zend_Registry, on the other hand, serves a much different purpose. Following the mantra "globals are evil", Zend_Regstry allows for a static place that objects can be stored so that they can be retrieved from a known place during the lifetime of a request. A typical scenario might be this: a bootstrap script creates a database object, or even a cacheManager object, then inside a controller script you need to retrieve those objects. Since the objects are inside of the application's registry, you know that is the place where they can be retrieved from. Zend_Registry does not persist objects between requests; meaning any contents will be destroyed at request end, and will need to be re-created on the next request to be used. Zend_Registry is more for code convenience, not performance.
Hope that helps,
Ralph
From: Volker Orgeldinger on behalf of sina miandashti
Sent: Tue 2/16/2010 12:45 AM
To: 'Zend MVC'
Subject: [fw-mvc] zend_registry or zend_cache_manager
hi all developers ;)
$cache = Zend_Cache::factory('Core','File',$frontend,$backend);
1:
$manager = new Zend_Cache_Manager;
$manager->setCache('appcache', $cache);
2:
Zend_Registry::set ( 'cache', $cache );
------------------------------------------------------------------------
which one is better for storing the $cache object ... ?
for better performance and better memory usage and etc...
--
________________
Sincerely
Sina Miandashti
MuSicBasE.ir & InvisionPower.ir Admin
$cache = Zend_Cache::factory('Core','File',$frontend,$backend);
1:
$manager = new Zend_Cache_Manager;
$manager->setCache('appcache', $cache);
2:
Zend_Registry::set ( 'cache', $cache );
------------------------------------------------------------------------
which one is better for storing the $cache object ... ?
for better performance and better memory usage and etc...
--
________________
Sincerely
Sina Miandashti
MuSicBasE.ir & InvisionPower.ir Admin
没有评论:
发表评论