Julian,

Am 11.02.2014 18:41, schrieb Julian Vidal:
> As mentioned in this pull
> request<https://github.com/zendframework/zf2/pull/5386>ZF2 does not
> provide per-item cache TTL like ZF1 did.
That's not correct 100%.
ZF2 cache storage adapter doesn't change TTL behavior of the storage itself.
So if the storage itself (like memcached, apc, xcache, ...) supports it
the ZF2 cache storage adapter supports it, too.

> I'm using per-item TTL all throughout a ZF1 app which I'm currently
> migrating to ZF2 and desperately need to be able to do this. If I need to
> configure another cache adapter for every different TTL, my config file be
> huge and very hard to maintain.
The TTL is an option of a storage adapter as it's an option how the
storage should handle items in it.
If you have different TTL definitions normally you have different types
of items which means you would need different configurations and storage
instances.
If you don't like that you need to write your own simple wrapper against
a storage as @Ocramius prototyped here:
https://github.com/zendframework/zf2/pull/5386#issuecomment-29381538

> At some point in the discussion, Matthew Weier O'Phinney suggests:
> "Implement a plugin to add Item based TTL for storages not supporting it
> natively"
>
> Unfortunately, as I mention on my
> comment<https://github.com/zendframework/zf2/pull/5386#issuecomment-34491161>,
> I don't know how to write this kind of plugin. My deadline is approaching
> so I will appreciate ANY pointers on this matter.
As @weierophinney pointed out "... for storages not supporting it
natively" - it's a great way of implementing it to make that behavior
available for storages like the filesystem or dba. It doesn't magically
change the API and allows a TTL argument ... -> it needs to fetch the
configured TTL option, calculate the expected expired time in base of
current time + TTL and store it together with the item. On reading it
needs to check the stored expire time and return a "Item not found"
behavior in cases it's expired.
An implementation would look similar to the current serializer plugin.

Currently I don't have enough time to do some more work I'm interested
in as we born our (first) adorable daughter :)

But I could assist :)

> Thanks!

Marc


-- 
List: [email protected]
Info: http://framework.zend.com/archives
Unsubscribe: [email protected]


Reply via email to