承接 remotelyliving/php-cache-adapter 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

remotelyliving/php-cache-adapter

Composer 安装命令:

composer require remotelyliving/php-cache-adapter

包简介

A lightweight PSR6 / PSR16 cache adapter library for common caching scenarios

README 文档

README

Build Status Total Downloads Coverage Status License Scrutinizer Code Quality

php-cache-adapter:

💰 A PSR-6 and PSR-16 Cache Implementation For PHP 💰

Use Cases

If you want a lightweight, no frills PSR-6 / PSR-16 cache Memcache, Redis, or Memory adapter, this is for you. This library as born out of the idea that many other libraries offer way too much functionality for cache adapters and end up being overly complex or underperformant.

This library seeks to address the three most common cache storage mechanisms in the PHP ecosystem and not much more.

Installation

composer require remotelyliving/php-cache-adapter

Usage

SimpleCache

Simple Cache is the PSR-16 implementation of a simple cache adapter. Below are the different adapters you can create and use.

// Memcached flavor Simple Cache
$memcached = new \Memcached();
$memcached->addServer($memcacheHost, $memcachePort);
$memcachedAdapter = RemotelyLiving\PHPCacheAdapter\SimpleCache\Memcached::create($memcached);

// Redis Simple Cache
$redis = new \Redis();
$redis->pconnect($redisHost, $redisPort, $timeout);
$redisAdapter = RemotelyLiving\PHPCacheAdapter\SimpleCache\Redis::create($redis);

// Memory / Runtime Simple Cache
$memoryAdapter = RemotelyLiving\PHPCacheAdapter\SimpleCache\Memory::create($maxItemsForArray); // can set max items to keep in array

// APCu
$apcu = RemotelyLiving\PHPCacheAdapter\SimpleCache\APCu::create();

// Chain adapter calls through all adapters until values are found in order of FIFO
// so here we would check memory first, then Memcache, then Redis
$chainAdapter = RemotelyLiving\PHPCacheAdapter\SimpleCache\Chain::create($memoryAdapter, $memcachedAdapter, $redisAdapter);

CacheItemPool

Cache Item Pool is the PSR-6 implementation this library provides. You can create a CacheItemPool with a cache extension OR any of the PSR-16 Simple Cache adapters.

$memcached = new \Memcached();
$memcached->addServer('127.0.0.1', 11211);


$redis = new \Redis();
$redis->pconnect('127.0.0.1', 6379, 30);

$memcacheCacheItemPool = RemotelyLiving\PHPCacheAdapter\CacheItemPool\CacheItemPool::createMemcached($memcached, 'namespace');
// OR
$redisCacheItemPool = RemotelyLiving\PHPCacheAdapter\CacheItemPool\CacheItemPool::createRedis($redis, 'namespace');
// OR
$inMemoryCacheItemPool = RemotelyLiving\PHPCacheAdapter\CacheItemPool\CacheItemPool::createMemory($maxItems, 'namespace');
// OR
$apcuCacheItemPool = RemotelyLiving\PHPCacheAdapter\CacheItemPool\CacheItemPool::createAPCu();
// OR
$cacheItemPool = RemotelyLiving\PHPCacheAdapter\CacheItemPool\CacheItemPool::createFromSimpleCache($chainAdapter, 'namespace');
// OR
$chain = RemotelyLiving\PHPCacheAdapter\CacheItemPool\ChainBuilder::create('namespace', 300)
    ->addMemory()
    ->addAPCu()
    ->addMemcached($memcached)
    ->addRedis($redis)
    ->build();

Future Development

  • Consider adding a filesystem storage mechanism

统计信息

  • 总下载量: 6
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 1
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2020-05-19

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固