2017 © Pedro Peláez
 

library cache-service

Simple cache service using SQLite to reduce multiple db queries

image

carloshb/cache-service

Simple cache service using SQLite to reduce multiple db queries

  • Tuesday, May 23, 2017
  • by carloshb
  • Repository
  • 1 Watchers
  • 0 Stars
  • 12 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 1 Open issues
  • 4 Versions
  • 0 % Grown

The README.md

carloshb/cache-service

Latest Stable Version Total Downloads Latest Unstable Version License, (*1)

Simple cache service using SQLite to reduce multiple db queries., (*2)

Basic information

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

How to install?

Install using composer, (*3)

composer require carloshb/cache-service 0.2.*

Or clone in or project., (*4)

How to change default configs?

Add PHP env:, (*5)

    $_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., (*6)

    $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., (*7)

    $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., (*8)

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

The Versions

23/05 2017

dev-develop

dev-develop

Simple cache service using SQLite to reduce multiple db queries

  Sources   Download

MIT

The Requires

 

The Development Requires

by Carlos Henrique Bernardes

23/05 2017

dev-master

9999999-dev

Simple cache service using SQLite to reduce multiple db queries

  Sources   Download

MIT

The Requires

 

The Development Requires

by Carlos Henrique Bernardes

23/05 2017

0.2.1

0.2.1.0

Simple cache service using SQLite to reduce multiple db queries

  Sources   Download

MIT

The Requires

 

The Development Requires

by Carlos Henrique Bernardes

12/05 2017

v0.1

0.1.0.0

Simple cache service using SQLite to reduce multiple db queries

  Sources   Download

MIT

The Requires

  • php >=7.0

 

The Development Requires

by Carlos Henrique Bernardes