2017 © Pedro Peláez
 

library php-easycache

A simple & fast script for caching 3rd party API calls easily in PHP.

image

iprodev/php-easycache

A simple & fast script for caching 3rd party API calls easily in PHP.

  • Sunday, February 5, 2017
  • by iprodev
  • Repository
  • 2 Watchers
  • 6 Stars
  • 298 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 2 Forks
  • 0 Open issues
  • 5 Versions
  • 2 % Grown

The README.md

PHP EasyCache

The PHP EasyCache Class is an easy & fast way to cache 3rd party API calls with lossless data compression support., (*1)

Install

Install via composer:, (*2)

{
    "require": {
        "iprodev/php-easycache": "~1.2"
    }
}

Run composer install then use as normal:, (*3)

require 'vendor/autoload.php';
$cache = new iProDev\Util\EasyCache();

Usage

A very basic usage example:, (*4)

$cache = new iProDev\Util\EasyCache();
$latest_tweet = $cache->get_data('tweet', 'http://search.twitter.com/search.atom?q=from:chawroka&rpp=1');
var_dump($latest_tweet);

A more advanced example:, (*5)

$cache = new iProDev\Util\EasyCache();
$cache->cache_path = 'cache/';
$cache->cache_time = 3600;

$data = $cache->get('identity_keyword');

if(!$data) {
    $data = $cache->get_contents('http://some.api.com/file.json');
    $cache->set('identity_keyword', $data);
}

var_dump($data);

An example with compressing data:, (*6)

$cache = new iProDev\Util\EasyCache();
$cache->compress_level = 9;

$data = $cache->get_data('identity_keyword', 'http://some.api.com/file.json');

var_dump($data);

API Methods

$data = "Some data to cache";

// Call EasyCache
$cache = new iProDev\Util\EasyCache();

// SET a Data into Cache
$cache->set('identity_keyword', $data);

// GET a Data from Cache
$data = $cache->get('identity_keyword');

// Check that the data is cached
$is_cached = $cache->is_cached('identity_keyword');

// Get the Data from URL and cache it
$data = $cache->get_data('identity_keyword', 'http://search.twitter.com/search.atom?q=from:chawroka&rpp=1');

// Helper function for retrieving data from url without cache
$data = $cache->get_contents('http://search.twitter.com/search.atom?q=from:chawroka&rpp=1');

// REMOVE a Cache item
$cache->delete('identity_keyword');

// REMOVES all Cache expired items
$cache->flush_expired();

// REMOVES all Cache items
$cache->flush();

Configuration

// Call EasyCache
$cache = new iProDev\Util\EasyCache();

// Path to cache folder (with trailing /)
$cache->cache_path = 'cache/';

// Cache file extension
$cache->cache_extension = '.cache';

// Length of time to cache a file (in seconds)
$cache->cache_time = 3600;

// Lossless data compression level. 1 - 9; 0 to disable
$cache->compress_level = 0;

Credits

PHP EasyCache was created by Hemn Chawroka from iProDev. Released under the MIT license., (*7)

The Versions

05/02 2017

dev-master

9999999-dev https://github.com/iprodev/PHP-EasyCache

A simple & fast script for caching 3rd party API calls easily in PHP.

  Sources   Download

MIT

The Requires

  • php >=5.3.0

 

cache simplecache simple cache fast cache easy cache fastcache easycache

13/02 2016

1.2.1

1.2.1.0 https://github.com/iprodev/PHP-EasyCache

A simple & fast script for caching 3rd party API calls easily in PHP.

  Sources   Download

MIT

The Requires

  • php >=5.3.0

 

cache simplecache simple cache fast cache easy cache fastcache easycache

13/07 2015

1.2.0

1.2.0.0 https://github.com/iprodev/PHP-EasyCache

A simple & fast script for caching 3rd party API calls easily in PHP.

  Sources   Download

MIT

The Requires

  • php >=5.3.0

 

cache simplecache simple cache fast cache easy cache fastcache easycache

12/07 2015

1.1.0

1.1.0.0 https://github.com/iprodev/PHP-EasyCache

A simple & fast script for caching 3rd party API calls easily in PHP.

  Sources   Download

MIT

The Requires

  • php >=5.3.0

 

cache simplecache simple cache fast cache easy cache fastcache easycache

06/07 2015

1.0.0

1.0.0.0 https://github.com/iprodev/PHP-EasyCache

A simple & fast script for caching 3rd party API calls easily in PHP.

  Sources   Download

MIT

The Requires

  • php >=5.3.0

 

cache simplecache simple cache fast cache easy cache fastcache easycache