g4 / mcache
mcache php library
Installs: 63 745
Dependents: 4
Suggesters: 0
Security: 0
Stars: 2
Watchers: 10
Forks: 5
Open Issues: 0
Requires
- php: >=8.2
- couchbase/couchbase: *
- g4/profiler: >=1.10.0
- g4/value-object: *
Requires (Dev)
- phpunit/phpunit: 10.*
Suggests
- ext-couchbase: ^4.0
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);
Available options
* bucket - string
* servers - array
* user - string
* pass - string
* persistent - bool
* timeout - int (default 2500000)
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...