Add PhutilKeyValueCache and some implementations
Summary:
This is basically a slightly-more-abstract version of Facebook's cache stack, without any of the cachekey callbacks (in SocialBB, I implemented something similar above this).
- PhutilKeyValueCache defines an abstract key-value cache interface with get/set/delete operations.
- PhutilKeyValueCacheStack allows you to compose several caches so they behave like a single cache with readthrough semantics (like request -> APC -> Memcache at Facebook).
Then there are cache implementations:
- PhutilKeyValueCacheAPC implements an APC-based cache.
- PhutilKeyValueCacheMemcache implements a memcache-backed cache.
- PhutilKeyValueCacheInRequest is like Facebook's $GLOBALS['CACHE'] (i.e., kind of a bad idea).
- PhutilKeyValueCacheOnDisk implements a disk-based cache. With clever use of getmypid() / posix_getppid() and such we can reasonably fake something like APC for non-APC installs.
Test Plan: Ran unit tests. This is a slightly modified version of code that worked correctly in SocialBB.
Reviewers: btrahan, vrana
Reviewed By: btrahan
CC: aran
Maniphest Tasks: T2062
Differential Revision: https://secure.phabricator.com/D3974