userfrosting/cache
最新稳定版本:4.5.0
Composer 安装命令:
composer require userfrosting/cache
包简介
Cache module for UserFrosting
关键字:
README 文档
README
| Branch | Build | Coverage | Style |
|---|---|---|---|
| master | |||
| develop | |
Louis Charette, 2017
Wrapper function for Laravel cache system for easier integration of the cache system in standalone projects. Refer to Laravel documentation for all cache related function. This wrapper support Laravel ArrayStore, FileStore, MemcachedStore and RedisStore.
Also include a namespace parameter to handle multiple cache instance on the same server or project.
Usage
For any store driver, you first need to create a new *Store, passing the config values for each of those stores. Once a new store instantiated, you need to use the instance function to get the cache instance.
To use one of the following stores, you first need to include add it to the use list of your class or php file.
If you need to use multiple cache instance on the same server (especially for Memcached and Redis drivers) or on the same project (for example, user based cache), you can use the namespace parameter in the *Store constructor. A namespace should always be a string.
Since he Laravel cache requires an instance of Illuminate\Container\Container, every *Store in this package will create
one automatically. If you want to reuse an existing Container, you can pass it to the *Store constructor.
While the namespace parameter is required for any *Store, all other parameters are optional, unless otherwise specified.
ArrayStore
The ArrayStore is a dummy store that doesn't really save anything. This can be used if you want to disable cache globally.
The ArrayStore accepts the namespace and Container parameters: new ArrayStore(string $namespace, Illuminate\Container\Container $app = null);
Example :
use UserFrosting\Cache\ArrayStore;
...
$cacheStore = new ArrayStore("global");
$cache = $cacheStore->instance();
$cache->get(...);
FileStore
The FileStore save file to the filesystem.
The FileStore accepts the namespace, path and Container parameters : new FileStore(string $namespace, string $path = "./", Illuminate\Container\Container $app = null);
Example :
use UserFrosting\Cache\FileStore;
...
$cacheStore = new FileStore("global", "./cache");
$cache = $cacheStore->instance();
$cache->get(...);
MemcachedStore
The MemcachedStore uses Memcached to efficiently handle caching.
Memcached should't be mistaken for the Memcache. Those are tow separate things !
The MemcachedStore accepts the namespace, config and Container parameters : new MemcachedStore(string $namespace, array $config = [], Illuminate\Container\Container $app = null);
Memcached config's array contain the settings for your Memcached instance. Default values are:
[
'host' => '127.0.0.1',
'port' => 11211,
'weight' => 100
]
Custom config can be overwritten using this parameter.
Example :
use UserFrosting\Cache\MemcachedStore;
...
$cacheStore = new MemcachedStore("global"); //Uses default Memcached settings
$cache = $cacheStore->instance();
$cache->get(...);
Example with custom server and port :
use UserFrosting\Cache\MemcachedStore;
...
$cacheStore = new MemcachedStore("global", [
'host' => '123.456.789.0',
'port' => '22122'
]);
$cache = $cacheStore->instance();
$cache->get(...);
RedisStore
The RedisStore uses Redis server to efficiently handle caching.
The RedisStore accepts the namespace, config and Container parameters : new RedisStore(string $namespace, array $config = [], Illuminate\Container\Container $app = null);
Redis config's array contain the settings for your Redis server. Default values are:
[
'host' => '127.0.0.1',
'password' => null,
'port' => 6379,
'database' => 0
]
Custom config can be overwritten using this parameter.
Example :
use UserFrosting\Cache\RedisStore;
...
$cacheStore = new RedisStore("global"); //Uses default Redis settings
$cache = $cacheStore->instance();
$cache->get(...);
Example with custom port and password :
use UserFrosting\Cache\RedisStore;
...
$cacheStore = new RedisStore("global", [
'password' => 'MyAwesomePassword',
'port' => '1234'
]);
$cache = $cacheStore->instance();
$cache->get(...);
Style Guide
Testing
userfrosting/cache 适用场景与选型建议
userfrosting/cache 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 45.12k 次下载、GitHub Stars 达 2, 最近一次更新时间为 2017 年 02 月 25 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「cache」 「userfrosting」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 userfrosting/cache 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 userfrosting/cache 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 userfrosting/cache 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
repository php library
A secure, modern user management system for PHP.
Form generator for UserFrosting V5
Laravel 5 - Repositories to the database layer
Breadcrumb service provider for UserFrosting V4
This Sprinkle provides a UI for core and custom site settings
统计信息
- 总下载量: 45.12k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 2
- 点击次数: 19
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2017-02-25