chrisullyott / simple-cache
Quick and easy data caching in the filesystem.
Installs: 7 308
Dependents: 1
Suggesters: 0
Security: 0
Stars: 0
Watchers: 2
Forks: 0
Open Issues: 0
Requires
- php: >=5.6.0
- chrisullyott/php-log: ^2.0
Requires (Dev)
- phpunit/phpunit: ^5
README
Quick and easy data caching in the filesystem.
Install
$ composer require chrisullyott/simple-cache
Instantiate
require 'vendor/autoload.php'; use ChrisUllyott\Cache; $cache = new Cache('cache_id');
Setting data
$cache->set("Some data");
Getting data
echo $cache->get(); // "Some data"
Clearing
$cache->clear();
Usage
<?php require 'vendor/autoload.php'; use ChrisUllyott\Cache; $cache = new Cache('my_key'); $data = $cache->get(); if (!$data) { $data = my_api_request(); $cache->set($data); } print_r($data);
Testing
$ ./vendor/bin/phpunit --configuration=./tests/phpunit.xml