utopia-php / cache
一个简单的缓存库,用于管理应用程序的缓存存储、加载和清除
0.10.2
2024-06-25 20:36 UTC
Requires
- php: >=8.0
- ext-json: *
- ext-memcached: *
- ext-redis: *
Requires (Dev)
- laravel/pint: 1.2.*
- phpstan/phpstan: 1.9.x-dev
- phpunit/phpunit: ^9.3
- vimeo/psalm: 4.13.1
- dev-master
- 0.10.2
- 0.10.1
- 0.10.0
- 0.9.1
- 0.9.0
- 0.8.0
- 0.7.0
- 0.6.1
- 0.6.0
- 0.5.0
- 0.4.2
- 0.4.1
- 0.4.0
- 0.3.0
- 0.2.3
- 0.2.2
- 0.2.1
- 0.2.0
- v0.1.1
- v0.1.0
- dev-feat-redis-sync
- dev-feat-github-action
- dev-feat-get-size
- dev-feat-add-push-pop
- dev-feat-detailed-filesystem-adapter-errors
- dev-feat-add-ping-method
- dev-feat-add-flush-method
- dev-feat-sharding-adapter
This package is auto-updated.
Last update: 2024-09-05 07:00:41 UTC
README
Utopia 框架缓存库是一个简单轻量级的库,用于管理应用程序的缓存存储、加载和清除。这个库旨在尽可能简单,易于学习和使用。此库由 Appwrite 团队 维护。
尽管这个库是 Utopia 框架 项目的一部分,但它不依赖于其他库,可以作为独立库与任何其他 PHP 项目或框架一起使用。
入门指南
使用 composer 安装
composer require utopia-php/cache
文件系统适配器
<?php require_once __DIR__ . '/../../vendor/autoload.php'; use Utopia\Cache\Cache; use Utopia\Cache\Adapter\Filesystem; $cache = new Cache(new Filesystem('/cache-dir')); $key = 'data-from-example.com'; $data = $cache->load($key, 60 * 60 * 24 * 30 * 3 /* 3 months */); if(!$data) { $data = file_get_contents('https://example.com'); $cache->save($key, $data); } echo $data;
贡献
目前我们仅支持文件系统适配器作为缓存存储使用,发送一个 pull request 以添加 redis、memcached 或您可能需要与此库一起使用的任何其他存储适配器。
系统需求
Utopia 框架需要 PHP 8.0 或更高版本。我们建议尽可能使用最新的 PHP 版本。
测试
要运行所有单元测试,请使用以下 Docker 命令
docker compose exec tests vendor/bin/phpunit --configuration phpunit.xml tests
要运行静态代码分析,请使用以下 Psalm 命令
docker-compose exec php8 vendor/bin/psalm --show-info=true
版权和许可
MIT 许可证 (MIT) http://www.opensource.org/licenses/mit-license.php