承接 bravo3/cache 相关项目开发

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

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

bravo3/cache

Composer 安装命令:

composer require bravo3/cache

包简介

A PHP 5.4 cache interface and various implementations including Redis and Bravo3/ORM

README 文档

README

This is a PHP 5.4 caching interface with implementations for common key/value storage engines.

PSR Proposal

The interfaces in this library abide by the current PSR-6 draft for caching interfaces. It should be known that should PHP-FIG adopt a PSR standard for caching interfaces, the interfaces in this library will be replaced with the PSR standard.

More info:

Subject To Change

The approach taken follows the 'strong item' or 'repository model' as per the above meta documentation. Should the PSR standard pass, there will be minimal change. Should an alternative approach pass, much of this library - and any implementations based on the interfaces - will need to be refactored.

A new major version number will be applied to this library when PSR-6 passes.

Usage

Basic usage:

$pool = new RedisCachePool('tcp://10.0.0.1:6379');
$item = $pool->get('foo');

$item->get();       // Pull the value from the database
$item->isHit();     // Check if the retrieval was a cache hit

$item->exists();    // Check if the entry exists in the datbase (MAY avoid actually retrieving the value)

$item->set('bar');  // Save to cache
$item->delete();    // Remove from cache

$items = $pool->getItems(['test1', 'test2', 'test3']);  // Get a collection of items

Using a TTL can be done with a \DateTime object or a integer offset in seconds:

$item = $pool->getItem('foo');

$dt = new \DateTime();
$dt->modify('+10 seconds');

$item->set('bar', $dt);   // Set TTL with a \DateTime object
$item->set('bar', null);  // Clear the TTL, item never expires
$item->set('bar', 10);    // Set the TTL to 10 seconds

Implementations

Ephemeral

The ephemeral implementation is a single-session storage that loses it's data when the session ends. This is useful for testing or a default implementation in lack of a real cache storage device. Or if you just really don't care about the volatility of your data.

Redis

Redis support is fully integrated via the Predis library.

To enable Redis support:

composer require predis/predis

Bravo3/ORM

You can use any Bravo3/ORM driver to connect a cache connection, this is useful to maintain a single source to your database.

To enable ORM support:

composer require bravo3/orm

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2014-03-30

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固