vitrexphp/cache
Composer 安装命令:
composer require vitrexphp/cache
包简介
Multiple Cache Component for PHP
关键字:
README 文档
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.
统计信息
- 总下载量: 6
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2020-02-20