承接 rothkj1022/php-cache-class 相关项目开发

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

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

rothkj1022/php-cache-class

Composer 安装命令:

composer require rothkj1022/php-cache-class

包简介

A simple file based cache based from Erik Giberti's FileCache class, forked from lodev09/php-cache-class.

README 文档

README

A simple file based cache based from Erik Giberti's FileCache class. See here

Enhanced Features

  • Data is serialized and JSON encoded
  • Cache data is encrypted by mcrypt
  • File Based Cache was explained here

Installation

Run the following command in your command line shell in your php project

$ composer require rothkj1022/php-cache-class

Done.

You may also edit composer.json manually then perform composer update:

"require": {
    "rothkj1022/php-cache-class": "^2.1.0"
}

Getting started

Example usage with composer

//load composer packages
require('vendor/autoload.php');

//create new instance of the class
use rothkj1022\FileCache;
$cache = new FileCache\FileCache("tmp/");

Example usage without composer

//require the class
require_once("lib/FileCache.php");

//create new instance of the class
use rothkj1022\FileCache;
$cache = new FileCache\FileCache("tmp/");

//...

Local file source example

$cache_key = "client_list";

//see if we can get an existing cache
if (!$clients_data = $cache->get($cache_key)) {
    //nope. Let's get the real one!
    $clients_data = json_decode(file_get_contents("clients.json"));

    //set the cache up!
    $expire = 3600; //1 hour
    $cache->set($cache_key, $clients_data, $expire);
}

var_dump($clients_data);

External http GET request example

$uri = 'https://raw.githubusercontent.com/bahamas10/css-color-names/master/css-color-names.json';
$remote_data = $cache->file_get_contents($uri);
var_dump($remote_data);

Reference

Code reference for you to get started!

Properties

  • protected $root = '/tmp/'; - Value is pre-pended to the cache, should be the full path to the directory.
  • protected $error = null; - For holding any error messages that may have been raised
  • private $_encryption_key = 'Fil3C@ch33ncryptionK3y' - Main key used for encryption (you need to set this up inside the class)

Methods

Public Methods

  • Cache::get($key) - Reads the data from the cache specified by the cache key
  • Cache::set($key [, $data, $ttl]) - Saves data to the cache. Anything that evaluates to false, null, '', boolean false, 0 will not be saved. $ttl Specifies the expiry time
  • Cache::delete($key) - Deletes the cache specified by the $key
  • Cache::get_error() - Reads and clears the internal error
  • Cache::have_error() - Can be used to inspect internal error

Private Methods

See code to see all private methods used like Cache::_encrypt($pure_string) etc.

Changelog

Version 2.1.3

  • Fixed: Stopped echoing guzzle request errors to screen

Version 2.1.2

  • Integrated guzzle for more efficient http get requests

Version 2.1.1

  • Changed: Renamed class back to Erik Giberti's original name, FileCache

Version 2.1.0

  • Added: Composer integration
  • Added: changelog

Credits

2010 - Authored by Erik Giberti 2011-2014 - Rewritten by Jovanni Lo / @lodev09 2018 - Modified by Kevin Roth / @rothkj1022

License

Released under the MIT License. See LICENSE file.

rothkj1022/php-cache-class 适用场景与选型建议

rothkj1022/php-cache-class 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 86 次下载、GitHub Stars 达 0, 最近一次更新时间为 2018 年 06 月 12 日, 在 PHP 生态内属于活跃度较高的组件。

我们在过去多个企业项目中使用过 rothkj1022/php-cache-class 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 rothkj1022/php-cache-class 我们能提供哪些服务?
定制开发 / 二次开发

基于 rothkj1022/php-cache-class 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2018-06-12