2017 © Pedro Peláez
 

library memento

Lightweight cache library

image

garyr/memento

Lightweight cache library

  • Monday, October 9, 2017
  • by garyr
  • Repository
  • 4 Watchers
  • 18 Stars
  • 3,387 Installations
  • PHP
  • 1 Dependents
  • 0 Suggesters
  • 4 Forks
  • 2 Open issues
  • 10 Versions
  • 4 % Grown

The README.md

Build Status, (*1)

Memento

Thin php caching wrapper for file, memcache, or redis storage engines. Supports simple key => data object storage and invalidation, as well as group based methods. Note that group bases methods always expire at the same time and should only be used when invalidation operations need to happen simultaneously, (*2)

Setup

$file = new Memento\Engine\File(
    array(
        'path' => '/tmp/memento',   // defaults to sys_get_temp_dir() . '/memento'
    )
);

// client instance (defaults to file based storage)
$memento = new Memento\Client($file);

Memcache Setup

$memcache = new Memento\Engine\Memcache(
    array(
        'host' => '127.0.0.1',
        'port' => 11211
    )
);

// client instance
$memento = new Memento\Client($memcache);

Redis Setup

$redis = new Memento\Engine\Redis(
    array(
        'host' => '127.0.0.1',
        'port' => 6379
    )
);

// client instance
$memento = new Memento\Client($redis);

Store Example

// single key store request
$memento->store(new Memento\Key('com.example.key'), array('mydata'));

$groupKey = new Memento\Group\Key('com.example.group1');

// group key store request (multiple keys per group key)
$memento->store(
    $groupKey,
    new Memento\Key('com.example.key1'),
    array('mydata')
);

$memento->store(
    $groupKey,
    new Memento\Key('com.example.key2'),
    array('foo' => 'bar')
);

Retrieve Example

// single key retrieve request
$data = $memento->retrieve(new Memento\Key('com.example.key'));

$groupKey = new Memento\Group\Key('com.example.group1');

// group key retrieve request
$data = $memento->retrieve(
    $groupKey,
    new Memento\Key('com.example.key1')
);

$data = $memento->retrieve(
    $groupKey,
    new Memento\Key('com.example.key2')
);

Invalidate Example

// single key invalidate request
$memento->invalidate(new Memento\Key('com.example'));

// group key store request (invalidate a group in a single operation)
$memento->invalidate(new Memento\Group\Key('com.example.group1'));

Sharding

For other than file based engines, sharding simply requires additional hosts. Sharding is accomplished based on the key supplied for the data and is pointed to a host (see Memento\Engine\EngineAbstract), (*3)

// redis sharding config example
$redis = new Memento\Engine\Redis(
    array(
        array(
            'host' => 'redis1.mydomain',
            'port' => 6379
        ),
        array(
            'host' => 'redis2.mydomain',
            'port' => 6379
        )
    )
);

// memcache sharding config example
$memcache = new Memento\Engine\Memcache(
    array(
        array(
            'host' => 'memcache1.mydomain',
            'port' => 11211
        ),
        array(
            'host' => 'memcache2.mydomain',
            'port' => 11211
        )
    )
);

The Versions

09/10 2017

dev-develop

dev-develop

Lightweight cache library

  Sources   Download

MIT

The Requires

 

The Development Requires

file cache redis memcache

09/10 2017

dev-master

9999999-dev

Lightweight cache library

  Sources   Download

MIT

The Requires

 

The Development Requires

file cache redis memcache

09/10 2017

1.1.2

1.1.2.0

Lightweight cache library

  Sources   Download

MIT

The Requires

 

The Development Requires

file cache redis memcache

09/08 2017

1.1.1

1.1.1.0

Lightweight cache library

  Sources   Download

MIT

The Requires

 

The Development Requires

file cache redis memcache

09/08 2017

dev-fixes-client-issue

dev-fixes-client-issue

Lightweight cache library

  Sources   Download

MIT

The Requires

 

The Development Requires

file cache redis memcache

08/08 2017

1.1.0

1.1.0.0

Lightweight cache library

  Sources   Download

MIT

The Requires

 

The Development Requires

file cache redis memcache

02/06 2015

1.0.3

1.0.3.0

Lightweight cache library

  Sources   Download

MIT

The Requires

 

The Development Requires

file cache redis memcache

13/04 2015

1.0.2

1.0.2.0

Lightweight cache library

  Sources   Download

MIT

The Requires

 

The Development Requires

file cache redis memcache

19/06 2014

1.0.1

1.0.1.0

Lightweight cache library

  Sources   Download

MIT

The Requires

 

The Development Requires

file cache redis memcache

18/06 2014

1.0

1.0.0.0

Lightweight cache library

  Sources   Download

MIT

The Requires

 

The Development Requires

file cache redis memcache