sharnw / filecached-php
There is no license information available for the latest version (dev-master) of this package.
A simple PHP key-value datastore using filesystem instead of memory
dev-master
2016-12-07 04:00 UTC
Requires
- php: >=5.3
This package is not auto-updated.
Last update: 2024-12-16 14:29:22 UTC
README
A simple key-value datastore using filesystem instead of memory.
Useful for caching large datasets, and replacing memcache on low memory AWS instances.
Credit to https://github.com/hustcc for the original.
Installation
Add the following line to your composer.json file:
{
"require": {
"sharnw/filecached-php": "dev-master"
}
}
Usage
Similar interface to memcache
set(k, v)
set key-value pairget(k)
get key value, returns false if nothing presentdelete(k)
delete key-value pairflush()
wipe all cache data
Demo
require_once('src/cache.php');
$cache = new Filecached\Cache();
$example_data = [
'time' => time(),
'message' => 'something certainly happened today.',
];
$cache->set('todays_news', $example_data);
print_r($storeData = $cache->get('todays_news'));
$example_data = [
[
'url' => 'https://libraries.io/github/hustcc/php-file-cache',
'title' => 'Forked repo'
],
];
$cache->set('todays_links', $example_data);
print_r($storeData = $cache->get('todays_links'));
$cache->flush('today_'); // flush all data in 'today/' namespace
$cache->set('more data', ['blah']);
$cache->flush(); // flush all data
License
Released under the terms of the MIT license.
Links
- Forked lib - https://libraries.io/github/hustcc/php-file-cache