PHP Cache library built by PSR-16 simple cache interface
You can find implementations of the specification by looking for packages providing the
psr/simple-cache-implementation
virtual package.
This library is installed via Composer. To install,
- simply add to your
composer.json
file:"sarahman/json-filesystem-cache": "^1.0"
OR
- run this command:
$ composer require sarahman/sarahman/json-filesystem-cache
- Create a file named
test.php
in your root directory and add these following codes:
<?php
require "vendor/autoload.php";
$cache = new Sarahman\SimpleCache\JSONFileSystemCache(); // the custom cache directory can be set through the parameter.
// Set Cache key.
$data = [
'sample' => 'data',
'another' => 'data'
];
$cache->set('your_custom_key', $data);
// Check cached key exists or not.
$cache->has('your_custom_key');
// Get Cached key data.
$cache->get('your_custom_key');
- Then run
php test.php
.
psr/simple-cache-implementation
If you are having general issues with this package, feel free to contact me through Gmail.
If you believe you have found an issue, please report it using the GitHub issue tracker, or better yet, fork the repository and submit a pull request.
If you're using this package, I'd love to hear your thoughts. Thanks!