定制 php-strict/storable-cache 二次开发

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

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

php-strict/storable-cache

Composer 安装命令:

composer require php-strict/storable-cache

包简介

Storable cache store items more than their lifetime, up to time to save.

README 文档

README

Software License Build Status codecov Codacy Badge

Storable cache store items more than their lifetime, up to time to save, and allow use stored items after expiration, in cases, for example, of db overload or errors.

Supported storages:

  • arrays (not real storage, only for testing),
  • files,
  • memcached,
  • redis,
  • SQLite,
  • MySQL (uses main db connection from app).

Requirements

Install

Install with Composer:

composer require php-strict/storable-cache

Usage

Basic usage:

use PhpStrict\Config\Config;
use PhpStrict\StorableCache\StorableCache;

//instance of application configuration class, extending Config
//must provide cacheType property with correct storable cache type
//see PhpStrict\StorableCache\StorageTypes class
$config = new AppConfig();
$config->loadFromFile('config.ini');

//instance of StorableCache
$cache = new StorableCache($config);

//part of generating content method
if ($cache->has('contentKey') && !$cache->expired('contentKey')) {
    return $cache->get('contentKey');
}
//part of generating content method

//saving generated content: key, value, ttl, tts (time to save)
$cache->set('contentKey', $content, 60, 3600);

Usage if content generating main process was failed and it is correct to use expired data:

use PhpStrict\StorableCache\StorableCache;

//part of generating content method

//generating content failed

if ($cache->has('contentKey')) {
    return $cache->get('contentKey');
}

throw Exception('Generating content failed');
//part of generating content method

Tests

To execute the test suite, you'll need Codeception.

vendor\bin\codecept run

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: GPL-2.0-or-later
  • 更新时间: 2019-04-12

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固