Add MemoizedCallable for APC-backed function memoization
authorOri Livneh <ori@wikimedia.org>
Mon, 5 Oct 2015 23:10:56 +0000 (16:10 -0700)
committerBryanDavis <bdavis@wikimedia.org>
Tue, 6 Oct 2015 23:35:03 +0000 (23:35 +0000)
commitda3443bfa2a925a7578f1378d7bfc1bb1acb4587
tree5c1cf107725ef1f4607479fedec3cfcf905e8dcc
parent96b23a432552350d690fd83a1a9ba86f32a3c35a
Add MemoizedCallable for APC-backed function memoization

Add a simple class to `libs/` for memoizing functions by caching return values
in APC. I decided not to make this an external library just yet because I see
this as potentially a part of a larger functional programming library.

Doesn't use APCBagOStuff for two reasons: (1) avoid dependency on MediaWiki
code; (2) ability to pass third &$success parameter to apc_store, to
distinguish between cache misses and cached false values.

Use this in ResourceLoaderFileModule to cache CSSMin::remap.

Change-Id: I00a47983a2583655d4631ecc9c6ba17597e36b5f
autoload.php
includes/libs/MemoizedCallable.php [new file with mode: 0644]
includes/resourceloader/ResourceLoaderFileModule.php
tests/phpunit/includes/libs/MemoizedCallableTest.php [new file with mode: 0644]