sonata-project / SonataCacheBundle

[Abandoned] This bundle provides caching services

Home Page:https://github.com/sonata-project/SonataCacheBundle

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Memcached expiration time

dkorsak opened this issue · comments

MemchedCache class set invalid expiration time of cache element.

TTL should be set as $cacheElement->getTtl() no as time() + $cacheElement->getTtl().

For example when you set time()+10 seconds - does not work and cache will not be set, but set 10 second will set cache for 10 seconds.

From documentation:

"Expiration times can be set from 0, meaning “never expire”, to 30 days. Any time higher than 30 days is interpreted as a unix timestamp date. If you want to expire an object on january 1st of next year, this is how you do that."

http://code.google.com/p/memcached/wiki/NewProgramming

Can you send a PR with a test case ? thanks

From what I understand from this page: http://fr2.php.net/manual/en/memcached.expiration.php

if a timestamp is used as the code does actually (time() + ttl) then memcached considers the value as a unix timestamp. it is what we want.

So the current implementation always works.

I just make some tests and you are right, fixing it.

tag 1.0.1 of sonata-project/cache