perf/caching 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

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

perf/caching

最新稳定版本:3.1.1

Composer 安装命令:

composer require perf/caching

包简介

Allows to store data with caching engines (Memcache, file system, etc).

README 文档

README

Allows caching of data (with Memcached, file-system, etc).

Usage

Initialization

<?php

use perf\Caching\CacheClient;
use perf\Caching\Storage\FileSystemCachingStorage;
use perf\Caching\Storage\MemcachedCachingStorage;
use perf\Caching\Storage\NullCachingStorage;
use perf\Caching\Storage\VolatileCachingStorage;

// Memcached
$storage = MemcachedCachingStorage::createFromCredentials('1.2.3.4', 123);
$cache   = CacheClient::createWithStorage($storage);

// Volatile storage
$storage = new VolatileCachingStorage();
$cache   = CacheClient::createWithStorage($storage);

// File-system storage
$storage = new FileSystemCachingStorage('/tmp/cache');
$cache   = CacheClient::createWithStorage($storage);

// Null storage (caches nothing)
$storage = new NullCachingStorage();
$cache   = CacheClient::createWithStorage($storage);

Storing and retrieving data

<?php

$objectToStore = new \stdClass();
$objectToStore->bar = 'baz';

$cache->store('foo', $objectToStore);

// ...

$object = $cache->tryFetch('foo');

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2015-03-23