[Cache] Removal of CacheItemPoolInterface Methods: Save, SaveDeferred & Commit

69 views
Skip to first unread message

Jon Whelan

unread,
Sep 16, 2014, 3:15:08 AM9/16/14
to php...@googlegroups.com
The CacheItemPoolInterface can be simplified and much of the discussion thus far surrounding the save, saveDeferred, and commit methods (particularly this thread: https://groups.google.com/forum/#!topic/php-fig/AhpJxOiwBz0) can be made irrelevant by pushing these persistence concerns back into being an implementation detail.

Why should the calling library know (or care about) when an item it sets on the pool is actually persisted to the database? The only thing the calling library should concern itself with is being able to get, set, and remove items from the pool. This is also consistent with the resource referenced here: https://groups.google.com/d/msg/php-fig/P7cFSg631TU/r6xF0tHu39MJ

If it is required or desired that the cache pool persist all cache items at once, then use a cache pool implementation that utilizes the Unit of Work pattern and then commit that UoW from some other place in the code, for instance, during the shutdown routine of the script. If you need the cache pool to persist to the database as soon as an item is added, then use an implementation that persists it as soon as the set method is called.
Reply all
Reply to author
Forward
0 new messages