Marc, It does seem a bit too much though that doesn't look right because in order to generate the key you'd need to pass the method name as well as the parameters in the same order. I don't think these patterns were intended for you to invalidate items manually (as odd as it might sound). In fact I've used a couple of them many times and have never needed to do that. I know this doesn't sound like a satisfying answer (sorry!). Perhaps someone else with a better understanding of these classes can hop in.
If you really want to invalidate cache items manually I suppose you could wrap this into something easier for you to use and forget about the patterns :) On Thu, Jun 5, 2014 at 3:57 AM, Marc Tempelmeier < [email protected]> wrote: > Ah, ok, got it. > > Thank you! > > Another question on removing an item: > > > $cachedFilter->getOptions()->storage->removeItem($cachedFilter->generateKey('filter')); > > Seems a bit too much, is there an easy way? > > > > Von: Julian Vidal [mailto:[email protected]] > Gesendet: Mittwoch, 4. Juni 2014 21:37 > An: Marc Tempelmeier > Cc: Zend Framework General > Betreff: Re: [fw-general] Zend\Cache\Pattern > > Normally you'd call $filter->filter('some/path') and this would return a > new path. Let's say you want to cache this call. In this case you have two > syntaxes available: > > $cacheOuput = $cachedFilter->filter('some/path'); > > // or > > $cacheOutput = $cachedFilter->call("filter", array('some/path')); > > Both are saying "Call the method filter() in the object that I specified > in $cachedFilter's configuration and pass it the string 'some/path' as its > parameter". > > Every time you pass it another string, it will generate another > (different) cache entry. > > If you look at the source, the ObjectPattern is just a subclass of the > CallbackPattern. More specifically, look at the call method and see how the > keys are generated. This should become clear then. > > On the other hand, st this up in your dev environment with a FileSystem > adapter and cache just one call. Look inside the cache file. Now cache a > second, different, call. Look inside the cache file. This will make it > perfectly clear what's happening. > > > On Wed, Jun 4, 2014 at 5:18 AM, Marc Tempelmeier < > [email protected]> wrote: > Hmm, I don“t get the parameter in the array, is there one cache entry per > parameter? > > $cachedFilter->call("filter", array('path1)); > $cachedFilter->call("filter", array('path2)); > > Generates 2 cache entries? > > > Von: Julian Vidal [mailto:[email protected]] > Gesendet: Mittwoch, 4. Juni 2014 10:22 > > An: Marc Tempelmeier > Cc: Zend Framework General > Betreff: Re: [fw-general] Zend\Cache\Pattern > > There's one in the documentation but you need to scroll all the way down > as the first example at the top only show how to create it and not saving > and loading: > http://framework.zend.com/manual/2.1/en/modules/zend.cache.pattern.object-cache.html > > What's strange in this example is that this filter is so fast that it > won't need caching but the idea is that you'd use this pattern while > calling a method that takes a considerable time to execute. > > $filter = new Zend\Filter\RealPath(); > $cachedFilter = Zend\Cache\PatternFactory::factory('object', array( > 'object' => $filter, > 'object_key' => 'RealpathFilter', > 'storage' => 'apc', > > // The realpath filter doesn't output anything > // so the output don't need to be caught and cached > 'cache_output' => false, > )); > > > > $path = $cachedFilter->call("filter", array('/www/var/path/../../mypath')); > // OR > $path = $cachedFilter->filter('/www/var/path/../../mypath'); > > On Wed, Jun 4, 2014 at 4:07 AM, Marc Tempelmeier < > [email protected]> wrote: > Can you provide a simple example for hmmm, the ObjectCache incl. saving > and loading? > > Von: Julian Vidal [mailto:[email protected]] > Gesendet: Dienstag, 3. Juni 2014 23:17 > An: Marc Tempelmeier > Cc: Zend Framework General > Betreff: Re: [fw-general] Zend\Cache\Pattern > > The "storage" is just an adapter that saves the data in different > locations depending on which adapter you use (disk, memcached, etc). > The patterns are much higher level and are designed to solve a specific > caching problem. The one I use most often is the CaptureCache. It is > designed to "capture" the output of a web page and store it into a file > while keeping the directory structure the same as the url. The pattern uses > a storage and not the other way around. > You could use just a storage to capture a web page but you'd have to code > a lot more to generate the files, create the directory structure, etc, etc. > That's what the pattern does. > Each pattern solves a specific high level problem if you will. Each > storage just deals with saving your data and that's it. > > On Tue, Jun 3, 2014 at 9:03 AM, Marc Tempelmeier < > [email protected]> wrote: > Hi, > > what ist he purpose of the cache patterns? > How can I use them? When should I use the storage or the pattern? > > Greetings > > Marc > > -- > List: [email protected] > Info: http://framework.zend.com/archives > Unsubscribe: [email protected] > > > >
