carloshb/cache-service 问题修复 & 功能扩展

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

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

carloshb/cache-service

Composer 安装命令:

composer require carloshb/cache-service

包简介

Simple cache service using SQLite to reduce multiple db queries

README 文档

README

Latest Stable Version Total Downloads Latest Unstable Version License

Simple cache service using SQLite to reduce multiple db queries.

Basic information

  • default cache time: 60mins
  • default cache path: Carloshb\CacheService\Driver

How to install?

Install using composer

composer require carloshb/cache-service 0.2.*

Or clone in or project.

How to change default configs?

Add PHP env:

    $_ENV['cache_time'] = 10; // minutes
    $_ENV['cache_path'] = 'yor/storage/path';

Usage

resolve(string $key, callable $callback [, int $time = 60]) : Cache

The method resolve() returns an instance of Cache class and generate or update the key sent with the callback return. First parameter is the key, a string. Second parameter is the callback, a function returning array with expected results. Third parameter is optional, for set n minutes for cache.

    $cache = new \Carloshb\CacheService\Cache();
    $cache->resolve('getInfo', function(){
        return array(
            'name' => 'Carlos Henrique Bernardes',
            'email' => 'contato@carloshb.com.br'
        );
    });

getCacheContent() : json

Use after resolve() to get a content of cache, the method returns a json.

    $cache = new \Carloshb\CacheService\Cache();
    $content = $cache->resolve('getInfo', function(){
        return array(
            'name' => 'Carlos Henrique Bernardes',
            'email' => 'contato@carloshb.com.br'
        );
    })->getCacheContent();

destroy(string $key) : bool

Use this method to force cache destroy using the key name.

    $cache = new \Carloshb\CacheService\Cache();
    $response = $cache->destroy('getInfo');
    var_dump($response); // true or false

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2017-05-12

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固