2017 © Pedro Peláez
 

library hcache

cache that boosts performance

image

nazg/hcache

cache that boosts performance

  • Monday, July 23, 2018
  • by ytake
  • Repository
  • 1 Watchers
  • 1 Stars
  • 77 Installations
  • Hack
  • 1 Dependents
  • 0 Suggesters
  • 0 Forks
  • 1 Open issues
  • 10 Versions
  • 8 % Grown

The README.md

Nazg\HCache

Build Status, (*1)

Installation

$ composer require nazg/hcache

Usage

supported apc, memcached, map, void, filesystem, (*2)

Using the CacheManager

<?hh
use Nazg\HCache\Element;
use Nazg\HCache\CacheManager;

$manager = new CacheManager();
$cache = $manager->createCache('memcached');
$mc = new \Memcached('mc');
$mc->addServers([['127.0.0.1', 11211]]);
$cache->setMemcached($mc);
$cache->createCache('map')?->save('cache', new Element('testing', 0));
cache name cache driver
apc \Nazg\HCache\Driver\ApcCache
void \Nazg\HCache\Driver\VoidCache
map \Nazg\HCache\Driver\MapCache
file \Nazg\HCache\Driver\FileSystemCache
memcached \Nazg\HCache\Driver\MemcachedCache
redis \Nazg\HCache\Driver\RedisCache

Cache Usage

Retrieving Item From The Cache

<?hh

  <<__Override>>
  public function fetch(string $id): mixed {

  }

Checking For Item Existence

<?hh

  <<__Override>>
  public function contains(string $id): bool {

  }

Storing Item In The Cache

<?hh

  <<__Override>>
  public function save(string $id, Element $element): bool {

  }

Removing Items From The Cache

remove item, (*3)

<?hh

  <<__Override>>
  public function delete(string $id): bool {

  }

flush, (*4)

<?hh

  <<__Override>>
  public function flushAll(): bool {
  }

Adding Custom Cache Drivers

<?hh

use Nazg\HCache\CacheManager;
use Nazg\HCache\CacheProvider;

$manager = new CacheManager();
$manager->addCache('null', () ==> new NullCache());
$manager->createCache('null');

class NullCache extends CacheProvider {
  <<__Override>>
  public function fetch(string $id): mixed {
    return;
  }

  <<__Override>>
  public function contains(string $id): bool {
    return false;
  }

  <<__Override>>
  public function save(string $id, Element $element): bool {
    return true;
  }

  <<__Override>>
  public function delete(string $id): bool {
    return true;
  }

  <<__Override>>
  public function flushAll(): bool {
    return true;
  }
}

Using Cache Providers

example, (*5)

FileSystemCache

<?hh
use Nazg\HCache\Element;
use Nazg\HCache\Driver\FileSystemCache;

$cache = new FileSystemCache();
$cache->setDirectory(__DIR__ . '/../storages');
$cache->save('file', new Element('testing', 0));

$cache->fetch('file');
$cache->contains('file')
$cache->flushAll();

MapCache (memory)

<?hh
use Nazg\HCache\Element;
use Nazg\HCache\Driver\MapCache;

$cache = new MapCache();
$cache->save('map', new Element('testing', 0));

MemcachedCache

<?hh
use Nazg\HCache\Element;
use Nazg\HCache\Driver\MemcachedCache;

$cache = new MemcachedCache();
$mc = new \Memcached('mc');
$mc->addServers([['127.0.0.1', 11211]]);
$cache->setMemcached($mc);
$cache->save("qwerty", new Element('testing:cache', 0));

The Versions

23/07 2018

dev-master

9999999-dev

cache that boosts performance

  Sources   Download

MIT

The Requires

 

The Development Requires

by Yuuki Takezawa

cache hack hhvm

23/07 2018

0.1.4

0.1.4.0

cache that boosts performance

  Sources   Download

MIT

The Requires

 

The Development Requires

by Yuuki Takezawa

cache hack hhvm

23/07 2018

dev-feature/versions

dev-feature/versions

cache that boosts performance

  Sources   Download

MIT

The Requires

 

The Development Requires

by Yuuki Takezawa

cache hack hhvm

02/07 2018

0.1.3

0.1.3.0

cache that boosts performance

  Sources   Download

MIT

The Requires

 

The Development Requires

by Yuuki Takezawa

cache hack hhvm

02/07 2018

dev-hotfix/wrong-exception-class

dev-hotfix/wrong-exception-class

cache that boosts performance

  Sources   Download

MIT

The Requires

 

The Development Requires

by Yuuki Takezawa

cache hack hhvm

07/05 2018

0.1.2

0.1.2.0

cache that boosts performance

  Sources   Download

MIT

The Requires

 

The Development Requires

by Yuuki Takezawa

cache hack hhvm

07/05 2018

dev-fixed/hhvm3.26-unbound-name-patch

dev-fixed/hhvm3.26-unbound-name-patch

cache that boosts performance

  Sources   Download

MIT

The Requires

 

The Development Requires

by Yuuki Takezawa

cache hack hhvm

07/04 2018

0.1.1

0.1.1.0

cache that boosts performance

  Sources   Download

MIT

The Requires

 

The Development Requires

by Yuuki Takezawa

cache hack hhvm

07/04 2018

dev-feature/added-redis-driver

dev-feature/added-redis-driver

cache that boosts performance

  Sources   Download

MIT

The Requires

 

The Development Requires

by Yuuki Takezawa

cache hack hhvm

04/04 2018

0.1.0

0.1.0.0

cache that boosts performance

  Sources   Download

MIT

The Requires

 

The Development Requires

by Yuuki Takezawa

cache hack hhvm