mezon / cache
Small cache script
Installs: 1 422
Dependents: 1
Suggesters: 0
Security: 0
Stars: 3
Watchers: 4
Forks: 0
Open Issues: 0
Requires
- php: >=7.2.0
- mezon/functional: >=1.0.0
- mezon/singleton: >=1.0.0
Requires (Dev)
- phpunit/phpunit: ^8.5
This package is auto-updated.
Last update: 2024-10-25 14:21:33 UTC
README
Intro
Mezon provides simple cache class. Wich will help you to test how caching will affect performance of your code. If the performance will be boosted, then you can implement more complex solutions for caching.
Installation
Just print in console
composer require mezon/cache
And that's all )
How to use?
First of all we need to create single instance of cache ("singleton" pattern is used):
$cache = Cache::getInstance();
Then we can add data to cache:
$cache->set('key', 'data to be stored');
After all data was added you need to store it to be able using it within other requests.
$cache->flush();
And then you can check if the key exists:
var_dump($cache->exists('key')); // bool(true) var_dump($cache->exists('unexisting-key')); // bool(false)
And then you can fetch data by it's key:
var_dump($cache->get('key')); // string('data to be stored')
That's all for now )