g4/mcache

mcache php library

Installs: 1 303

Dependents: 2

Stars: 1

Watchers: 4

Forks: 1

Language: PHP

0.8.2 2015-03-25 12:50 UTC

README

mcache - php cache wrapper library

Install

Install through composer package manager. Find it on packagist.

composer require g4/mcache

Supported caching systems

Usage

Memcached instance

<?php

$driverName = 'Libmemcached';
$options = array(
    'servers' => array(
        '127.0.0.1:11211'
    );
);
$prefix = 'my_prefix';

$mcache = \G4\Mcache\McacheFactory::createInstance($driverName, $options, $prefix);

Couchbase instance

<?php

$driverName = 'Couchbase';
$options = array(
    'bucket' => 'my_bucket',
    'servers' => array(
        '127.0.0.1:8091'
    );
);
$prefix = 'my_prefix';

$mcache = \G4\Mcache\McacheFactory::createInstance($driverName, $options, $prefix);

Methods

<?php

// Get from cache
$value = $mcache
    ->key('my_key')
    ->get();

// Save to cache
$mcache
    ->key('my_key')
    ->value('my_value')
    ->set();

// Sava to cache with expiration
$mcache
    ->key('my_key')
    ->value('my_value')
    ->expiration(3600) // in seconds (default 0)
    ->set();

// Delete from cache
$mcache
    ->key('my_key')
    ->delete();

// Replace a value
$mcache
    ->key('my_key')
    ->value('my_value')
    ->replace();

Development

Install dependencies

$ make install

Run tests

$ make test

License

(The MIT License) see LICENSE file for details...