vitrexphp / cache
Multiple Cache Component for PHP
1.0.1
2020-02-20 20:56 UTC
Requires
- php: ^7.4
This package is auto-updated.
Last update: 2025-07-23 15:27:00 UTC
README
OVERVIEW
This is a simple PHP Cache Abstraction Layer for PHP 7.4 that provides a simple interaction with several cache mechanism.
Vitrex PHP Cache
provides the ability to cache frequently accessed content via several different adapters.
Depending on the server environment and what's available, an application can use one of the following
cache adapters:
- File (directory on disk)
- Memcache (cache service)
- Session (short-term caching in session)
INSTALL
Download the latest version from here.
Install Vitrex PHP Cache
using Composer.
composer require vitrexphp/cache
BASIC USAGE
Setting up the different cache object adapters
<?php use Vitrex\Cache\Cache; use Vitrex\Cache\Adapter; $File = new Adapter\File(__DIR__); $Session = new Adapter\Session(); $MemCached = new Adapter\Memcached(); /* Then inject one of the adapters into the main cache object */ $Cache = new Cache($File);
Save and load data from cache
Once a cache object is created, you can simply save and load data from it like below:
<?php if (($cacheData = $Cache->load('Foo')) === false) { $cacheData = [ 'Name' => 'Vitrex PHP Cache', 'Class' => Cache::class, 'LifeTime' => Adapter\Adapter::LIFE_TIME_1_WEEK, 'Foo' => 'Bar' ]; $Cache->save('Foo', $cacheData, '1 WEEK'); } var_dump($cacheData); ?>
Deleting cache file
$Cache->delete('Foo');
Clear all cache files
$Cache->clearAll();
SUPPORT
For support please visit: Github | Issues For donations please visit: PayPal For professional support please contact by e-mail.