定制 slabphp/cache-manager 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

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

slabphp/cache-manager

Composer 安装命令:

composer require slabphp/cache-manager

包简介

SlabPHP Cache Manager Library

README 文档

README

The SlabPHP Cache Management Driver Library wraps several different types of cache providers and gives a single interface to them.

This library is deprecated but since it's still part of the SlabPHP monorepo it's being open sourced as well. There are better alternatives that adopt PSR standards that you should use. The author of this library doesn't even consider wrapping all these different libraries together as a good pattern for cache. Please see the main SlabPHP documentation for more information about this and the other SlabPHP repositories.

Installation and Setup

First include this with composer:

composer require slabphp/cache-manager

Then create your provider object:

$provider = new \Slab\Cache\Providers\Predis();
$provider
    ->setHost('locallhost', 6379);

$driver = new \Slab\Cache\Driver();
$driver
    ->setProvider($provider);

Usage

Using a Request Object

The Request object is designed to wrap the getting and setting of cache in one basic step.

$request = new \Slab\Cache\Request();

$request
    ->setCacheKey('my-key')
    ->setCacheTTL(3600)
    ->setCallback($someObject, 'someCallBackFunction', ['value1'])
    ->setForceRefresh(!empty($_GET['cacheRefresh']));

$output = $driver->execute($request);

What this does is first check the set cache provider for a value with the key 'my-key'. If it exists, it will return it. Otherwise, it will execute $someObject->someCallBackFunction('value1'), save the value with key 'my-key' and a ttl of 3600 seconds, and then return it.

Other ways

You can do get(), set(), and delete() on the driver and they will pass through to the provider. You can also do ->getProvider() on the driver to perform any provider specific actions.

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: Apache-2.0
  • 更新时间: 2018-03-02

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固