aviat/banker
Composer 安装命令:
composer require aviat/banker
包简介
A caching library implementing PSR-6 (psr/cache) and PSR-16 (psr/simple-cache)
README 文档
README
A Caching library implementing the PSR-6 and PSR-16 interfaces for several common cache backends
Cache Backends
- Apcu
- Memcached
- Redis
- Null - no persistence
Basic Usage (SimpleCache/PSR-16)
<?php
// $config is the configuration array
// $logger is an optional psr/log compatible logger
$cache = new Aviat\Banker\Teller($config, $logger);
// Get a value from the cache, returning $defaultValue
// if the value doesn't exist in the cache
$value = $cache->get($key, $defaultValue);
// Save a new value at the specified key
$saved = $cache->set($key, 'newValue');
Basic Usage (Pool/PSR-6)
<?php
// Create the pool
// $config is the configuration array
// $logger is an optional psr/log compatible logger
$pool = new Aviat\Banker\Pool($config, $logger);
// Grab an item from the cache
$item = $pool->getItem('foo');
// Was there a cache hit?
if ( ! $item->isHit())
{
// ... Generation of value to cache
$item->set($value);
$item->save();
}
else
{
$value = $item->get();
}
Configuration / Connection array
The config array passed to the Pool class constructor determines which server to connect to. Regardless of the backend, the basic structure is like so:
<?php
$config = [
'driver' => 'null', // null, apcu, redis, memcached
'connection' => [
// Optional (For some drivers):
// driver setup, see below for the structure for each
// driver
],
'options' => [
// Optional:
// Set additional driver-specific options, like persistence for
// Memcached, or a prefix for Redis keys
]
];
Below are the connection arrays for each backend:
Memcached:
<?php
$config['connection'] = [
'host' => 'localhost', // hostname or socket
'port' => 11211, // Port needs to be 0 if socket
'persistent' => false, // Use persistent connection
];
Redis: See Predis documentation. An empty array will connect to localhost on port 6379.
Null, Apcu: No connection parameters
aviat/banker 适用场景与选型建议
aviat/banker 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 2.89k 次下载、GitHub Stars 达 0, 最近一次更新时间为 2016 年 09 月 07 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「redis」 「cache」 「memcached」 「psr-6」 「psr6」 「psr16」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 aviat/banker 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 aviat/banker 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 aviat/banker 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Memcached Bundle
repository php library
Simple to use mutex implementation that can use flock, memcache, memcached, mysql or redis for locking
A Symfony bundle for Mutex implementation for PHP
Microservice RPC through message queues.
Graphic stand-alone administration for memcached to monitor and debug purpose
统计信息
- 总下载量: 2.89k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 4
- 依赖项目数: 2
- 推荐数: 1
其他信息
- 授权协议: MIT
- 更新时间: 2016-09-07