- Add Item::setTtl() and Item::getTtl() methods. getTtl() returns the
number of seconds that the cache item was supposed to live for, NOT how
many it has left. (getTtl() feels a little weird to me; feedback welcome.)
- Add Item::getExpiration(). It returns the DateTime at which the item
will expire.
- Leave the $ttl parameter on set() as a convenient shorthand, such that
the following two statements must be identical:
$item->setTtl(300)->set('bar');
$item->set('bar', 300);
- Add a save() method to persist a cache object. Syntactically from the
above it seems prettier to put it on Item, but I could be convinced
otherwise.
- Add a Pool::set($key, $value, $ttl). It MUST be exactly equivalent to
the following (and in most cases would probably be almost exactly this
code internally):
$item = $pool->getItem($key);
$item->setTtl($ttl)->set($value)->save();
return $item;
...
Thoughts?
- Add a Pool::set($key, $value, $ttl).
* I'm honestly not sure how I feel about the "save" function. For some reason I don't like it, but I can't actually logic something up at the moment to justify why.
--
You received this message because you are subscribed to the Google Groups "PHP Framework Interoperability Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to php-fig+u...@googlegroups.com.
To post to this group, send email to php...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/php-fig/1e731e9e-44d8-4e32-a9ca-fcd1e03cd6cc%40googlegroups.com.
Hi,Providing a CacheItem->save() violates SRP, where CacheItem is not only responsible to hold its state, but also to know how to persist itself.
First of all, by doing this you create an architectural bidirectional dependency. CacheItem cannot live without CacheDriver. If CacheItem is supposed to be a VO, then it should have no dependencies at all. CacheDriver already have to know about CacheItem, so why enforce a bidirectional dependency (which is the root of all evil *cough* unmantainable code) for the sole purpose of being handy?I'll try to expose my line of thinking another way. Do you guys think the Connection (Pool, CacheDriver, whatever) that is responsible to store/retrieve/remove from driver should delegate this operation to an Item where its purpose is to represent a single element of the cache connection? It seems the Connection is already responsible for this, so why delegate it to the entry representation?
Also, objects that contains too many methods are bad in general thanks to our awesome memory manager in PHP. That's the reason why ActiveRecord implementations suffer on performance because of all 4 bytes of pointers to a method each PHP object instance have to store. When dealing with large volumes of Items, this will lead to a memory overhead we could/should avoid.
As of TTL, I already explained in another thread why it should be moved out of CacheItem.
Cheers,--
On Wed, Jul 3, 2013 at 2:03 PM, Josh Hall-Bachner <charl...@gmail.com> wrote:On Wednesday, July 3, 2013 12:01:39 AM UTC-7, Larry Garfield wrote:I'm not a big fan of this. I don't feel like the benefit is worth either the complication this introduces or the confusion of roles it brings about.
- Add a Pool::set($key, $value, $ttl).
I do like moving setTtl() to a separate method and adding getExpiration() though; that will help this proposal lead by example for any future extensions.
On Wednesday, July 3, 2013 12:48:01 AM UTC-7, Robert Hafner wrote:
* I'm honestly not sure how I feel about the "save" function. For some reason I don't like it, but I can't actually logic something up at the moment to justify why.
In the most common use case it transforms a single call to set into a multiple-call process, which feels kind of awkward. I do think it's probably the best way to solve the extensibility problem though.
--To view this discussion on the web visit https://groups.google.com/d/msgid/php-fig/1e731e9e-44d8-4e32-a9ca-fcd1e03cd6cc%40googlegroups.com.
You received this message because you are subscribed to the Google Groups "PHP Framework Interoperability Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to php-fig+u...@googlegroups.com.
To post to this group, send email to php...@googlegroups.com.
Guilherme Blanco
MSN: guilher...@hotmail.com
GTalk: guilhermeblanco
Toronto - ON/Canada--
You received this message because you are subscribed to the Google Groups "PHP Framework Interoperability Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to php-fig+u...@googlegroups.com.
To post to this group, send email to php...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/php-fig/CAFp73XsmTR0drBTMjuhf6xiKU99MjE-A1XLpV55ZnOAC%3Dt-nGA%40mail.gmail.com.
Earlier, we had a bit of a back and forth regarding "where does the save() method go?" I had forgotten when I started the poll earlier that, in fact, the current proposal doesn't have a save() method anywhere. :-) Item::set() is its own commit.
I'm not sure I like that. While it's certainly shorter to write this:
$pool->getItem('foo')->set('bar', 300);
Than either of these:
$pool->getItem('foo')->set('bar', 300)->save().
$pool->save($pool->getItem('foo')->set('bar', 300));
--Larry Garfield
--
You received this message because you are subscribed to the Google Groups "PHP Framework Interoperability Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to php-fig+unsubscribe@googlegroups.com.
To post to this group, send email to php...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/php-fig/51D3CC53.2050607%40garfieldtech.com.
To unsubscribe from this group and stop receiving emails from it, send an email to php-fig+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/php-fig/CAKxcST8VbQcuMyijCYEm6Bbo5WZorNuSm7OUGWfPmw9tvBmtQw%40mail.gmail.com.
It was towards having a Pool->set($key, $value, $tll) or Pool->set(CacheItem $item) and derivate methods.Paul,Strong vs. Weak had nothing to do with CacheItem->save() or not.
To view this discussion on the web visit https://groups.google.com/d/msgid/php-fig/CAFp73Xtsx-2PdzFtxd13pfSS36aCOV5LNAvq_gE_DEBe%2BAYiuQ%40mail.gmail.com.
On Thu, Jul 4, 2013 at 3:16 PM, guilher...@gmail.com <guilher...@gmail.com> wrote:
It was towards having a Pool->set($key, $value, $tll) or Pool->set(CacheItem $item) and derivate methods.Paul,Strong vs. Weak had nothing to do with CacheItem->save() or not.
I did ask multiple times for someone to explain the diff to me in code, thanks for that.
--
You received this message because you are subscribed to the Google Groups "PHP Framework Interoperability Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to php-fig+u...@googlegroups.com.
To post to this group, send email to php...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/php-fig/51D5B931.4000600%40garfieldtech.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/php-fig/CAA88B97WR0VwKjVfRJn4Syq04HKKOHzNM5Wx-tm1e8F2Kw2E5w%40mail.gmail.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/php-fig/CAF%2Bu_BzW2mk3ua664iVTVo8QaHtwr5ktDSoPZJWiQqpHDbKO%3Dg%40mail.gmail.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/php-fig/CAFp73XsnX6J5B1QFPAJASfrN29fHGPUt%3D3aQXiDL%3DNiqNczzZA%40mail.gmail.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/php-fig/39f4e2dc-18da-4692-bd79-3ca0b9f87c77%40googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/php-fig/CAF%2Bu_BxcdkakuVHcOfdh78QAx6hA1%2B8KmduSEkXo4Q9__3%2BJ9A%40mail.gmail.com.
--
You received this message because you are subscribed to the Google Groups "PHP Framework Interoperability Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to php-fig+u...@googlegroups.com.
To post to this group, send email to php...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/php-fig/CAF%2Bu_BxcdkakuVHcOfdh78QAx6hA1%2B8KmduSEkXo4Q9__3%2BJ9A%40mail.gmail.com.
For more options, visit https://groups.google.com/groups/opt_out.
--
You received this message because you are subscribed to the Google Groups "PHP Framework Interoperability Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to php-fig+u...@googlegroups.com.
To post to this group, send email to php...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/php-fig/CANqRZ1OtAH4zbC3NnfumS8qrhjhVHLurPV-tw1j0FkBAWTwFmg%40mail.gmail.com.
For more options, visit https://groups.google.com/groups/opt_out.
// We know that no cached item was found. That is to be expected
// when there are TTLs involved, as we want misses to happen so that
// we know to regenerate the value. As FGM said, a cache miss is not
// an abnormal or exceptional event so an Exception is inappropriate.
// Remember, throwing an exception is actually quite expensive since
// PHP has to generate a full stack trace to do so. It shouldn't be used
// for mundane flow of control.
}
--
You received this message because you are subscribed to the Google Groups "PHP Framework Interoperability Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to php-fig+u...@googlegroups.com.
To post to this group, send email to php...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/php-fig/fe8453ae-d656-476b-b05d-47302404c8d4%40googlegroups.com.
--
You received this message because you are subscribed to the Google Groups "PHP Framework Interoperability Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to php-fig+u...@googlegroups.com.
To post to this group, send email to php...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/php-fig/1fc36f91-719d-4685-91cf-12b65e4faa93%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
--
You received this message because you are subscribed to the Google Groups "PHP Framework Interoperability Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to php-fig+u...@googlegroups.com.
To post to this group, send email to php...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/php-fig/51D88F81.8080405%40garfieldtech.com.
There is also another issue, regarding multiple operations. Assuming you requested multiple keys and one of them only resulted in a miss, you still have to throw an exception and filter the hit results out of the exception data, or throw away the whole set, which would be a waste.
To view this discussion on the web visit https://groups.google.com/d/msgid/php-fig/CD73E675-660F-41E0-8F28-80E3681829D6%40gmail.com.