2017 © Pedro Peláez
 

library retain-cache-on-data-absent

Code allow restore data in cache if new data can not be retrieved.

image

andydune/retain-cache-on-data-absent

Code allow restore data in cache if new data can not be retrieved.

  • Monday, July 23, 2018
  • by AndyDune
  • Repository
  • 1 Watchers
  • 0 Stars
  • 1 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 4 Versions
  • 0 % Grown

The README.md

RetainCacheOnDataAbsent

Build Status Software License Packagist Version Total Downloads, (*1)

It allows to restore data in cache if new data can not be retrieved., (*2)

Installation

Installation using composer:, (*3)

composer require andydune/retain-cache-on-data-absent

Or if composer was not installed globally:, (*4)

php composer.phar require andydune/retain-cache-on-data-absent

Or edit your composer.json:, (*5)

"require" : {
     "andydune/retain-cache-on-data-absent": "^1"
}

And execute command:, (*6)

php composer.phar update

Problem

Yor script gets data from external API. For example currency rate from crr., (*7)

There is no need to extract data every time it is needed. So we are using cache. But what will be if cache get old, but no data appears from api? There is network error or bank site breakage., (*8)

This little library helps to avoid data absent from retriever. Cached data do not expires and if no new data appears it uses old data from cache., (*9)

Using

use Symfony\Component\Cache\Simple\FilesystemCache;
use AndyDune\RetainCacheOnDataAbsent\Cache;

$cacheAdapter = new FilesystemCache('test', 3600, '<root cache dir>');
$cache = new Cache($cacheAdapter, function () {
    /*
        $data = false; // no data - return data from old cache
        $data = 'very useful data to cache and use'; // update cache and return this data
    */
    return $data;
});
$result = $cache->get('data'); // use any key - it is used only for cache key 

The Versions

23/07 2018

dev-master

9999999-dev https://github.com/AndyDune/RetainCacheOnDataAbsent

Code allow restore data in cache if new data can not be retrieved.

  Sources   Download

MIT

The Requires

  • php >=5.6

 

The Development Requires

cache php

19/06 2018

v1.1.1

1.1.1.0 https://github.com/AndyDune/RetainCacheOnDataAbsent

Code allow restore data in cache if new data can not be retrieved.

  Sources   Download

MIT

The Requires

  • php >=5.6

 

The Development Requires

cache php

19/06 2018

v1.1.0

1.1.0.0 https://github.com/AndyDune/RetainCacheOnDataAbsent

Code allow restore data in cache if new data can not be retrieved.

  Sources   Download

MIT

The Requires

  • php >=5.6

 

The Development Requires

cache php

18/06 2018

v1.0.0

1.0.0.0 https://github.com/AndyDune/RetainCacheOnDataAbsent

Code allow restore data in cache if new data can not be retrieved.

  Sources   Download

MIT

The Requires

  • php >=5.6

 

The Development Requires

cache php