marvin255/in-memory-cache
Composer 安装命令:
composer require marvin255/in-memory-cache
包简介
Array based cache for PHP
README 文档
README
Simple PSR-16 implementation that uses an internal array to store data.
Usage
use Marvin255\InMemoryCache\InMemoryCache; $maxCacheSize = 10000; // only 10000 can be stored by this object $defaultTTL = 60; // 60 seconds as default TTL $cache = new InMemoryCache($maxCacheSize, $defaultTTL);
Decorator
The decorator allows you to use two caches at the same time. All data from the base cache (e.g. a Redis-based cache) will also be stored in InMemoryCache. This decorator can reduce the number of requests for long-running PHP processes.
use Marvin255\InMemoryCache\InMemoryCache; use Marvin255\InMemoryCache\CompositeCache; $maxCacheSize = 10000; // only 10000 can be stored by this object $defaultTTL = 60; // 60 seconds as default TTL $inMemoryCache = new InMemoryCache($maxCacheSize, $defaultTTL); $redisCache = new MyAwesomeRedisCache(); $decorator = new CompositeCache($inMemoryCache, $redisCache); $decorator->get('test'); // this call will trigger a request to Redis and save the data to memory $decorator->get('test'); // this call won't trigger any requests and will just return data from memory
统计信息
- 总下载量: 2.09k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 1
- 依赖项目数: 1
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2021-05-10