2017 © Pedro Peláez
 

library wordpress-psr-cache

image

thegallagher/wordpress-psr-cache

  • Saturday, May 27, 2017
  • by thegallagher
  • Repository
  • 1 Watchers
  • 4 Stars
  • 37 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 1 Versions
  • 9 % Grown

The README.md

WordPress PSR-6 and PSR-16 Implementation Using Transients

This library should be considered alpha and could change at any time. It is recommended that you specify a commit when using composer., (*1)

Installation

composer require thegallagher/wordpress-psr-cache:dev-master@dev

Usage Examples

getItem($cacheKey);
if (!$cacheItem->isHit()) {
    $value = SomeClass::someLongRunningMethod();
    $cacheItem->set($value);
    $cacheItem->expiresAfter($cacheTtl);
}
echo $cacheItem->get();

// PSR-16
use TheGallagher\WordPressPsrCache\SimpleCache;

$cacheKey = 'the_cache_item_key';
$cacheTtl = 600;
$cache = new SimpleCache();
$value = $cache->get($cacheKey);
if ($value === null) {
    $value = SomeClass::someLongRunningMethod();
    $cache->set($cacheKey, $value, $cacheTtl);
}
echo $value;
?>

Notes

  • Stored values are effectively serialized twice, because the Transient API has no way to tell the difference between storing false and a cache miss.
  • CacheItemPool::clear() always fails because the Transient API doesn't allow all values in transients to be cleared. This also applies to SimpleCache::clear() by default, since it proxies CacheItemPool.

License

The library is open-sourced software licensed under the MIT license., (*2)

The Versions

27/05 2017

dev-master

9999999-dev

  Sources   Download

MIT

The Requires

 

The Development Requires

by David Gallagher