2017 © Pedro Peláez
 

library cache

Provides an cache interface for several adapters Apc, Apcu, File, Mongo, Memcache, Memcached, Mysql, Mongo, Redis is supported.

image

desarrolla2/cache

Provides an cache interface for several adapters Apc, Apcu, File, Mongo, Memcache, Memcached, Mysql, Mongo, Redis is supported.

  • Tuesday, June 26, 2018
  • by desarrolla2
  • Repository
  • 9 Watchers
  • 108 Stars
  • 358,388 Installations
  • PHP
  • 41 Dependents
  • 3 Suggesters
  • 38 Forks
  • 25 Open issues
  • 25 Versions
  • 8 % Grown

The README.md

Desarolla2 Cache

A simple cache library, implementing the PSR-16 standard using immutable objects., (*1)

life-is-hard-cache-is, (*2)

Caching is typically used throughout an applicatiton. Immutability ensure that modifying the cache behaviour in one location doesn't result in unexpected behaviour due to changes in unrelated code., (*3)

Desarolla2 Cache aims to be the most complete, correct and best performing PSR-16 implementation available., (*4)

Latest version ![Latest version][ico-pre-release] Software License Build Status Coverage Status ![Quality Score][ico-code-quality] Total Downloads ![Today Downloads][ico-today-downloads] [Gitter][link-gitter], (*5)

Installation

composer require desarrolla2/cache

Usage

``` php use Desarrolla2\Cache\Memory as Cache;, (*6)

$cache = new Cache();, (*7)

$value = $cache->get('key');, (*8)

if (!isset($value)) { $value = do_something(); $cache->set('key', $value, 3600); }, (*9)

echo $value; ```, (*10)

Adapters

The following implementation allows you to combine cache adapters., (*11)

Options

You can set options for cache using the withOption or withOptions method. Note that all cache objects are immutable, setting an option creates a new object., (*12)

TTL

All cache implementations support the ttl option. This sets the default time (in seconds) that cache will survive. It defaults to one hour (3600 seconds)., (*13)

Setting the TTL to 0 or a negative number, means the cache should live forever., (*14)

Methods

PSR-16 methods

Each cache implementation has the following Psr\SimpleCache\CacheInterface methods:, (*15)

get(string $key [, mixed $default])

Retrieve the value corresponding to a provided key, (*16)

has(string $key)

Retrieve the if value corresponding to a provided key exist, (*17)

set(string $key, mixed $value [, int $ttl])

Add a value to the cache under a unique key, (*18)

delete(string $key)

Delete a value from the cache, (*19)

clear()

Clear all cache, (*20)

getMultiple(array $keys)

Obtains multiple cache items by their unique keys, (*21)

setMultiple(array $values [, int $ttl])

Persists a set of key => value pairs in the cache, (*22)

deleteMultiple(array $keys)

Deletes multiple cache items in a single operation, (*23)

Additional methods

The Desarrolla2\Cache\CacheInterface also has the following methods:, (*24)

withOption(string $key, string $value)

Set option for implementation. Creates a new instance., (*25)

withOptions(array $options)

Set multiple options for implementation. Creates a new instance., (*26)

getOption(string $key)

Get option for implementation., (*27)

Packers

Cache objects typically hold a Desarrolla2\Cache\Packer\PackerInterface object. By default, packing is done using serialize and unserialize., (*28)

Available packers are:, (*29)

  • SerializePacker using serialize and unserialize
  • JsonPacker using json_encode and json_decode
  • NopPacker does no packing
  • MongoDBBinaryPacker using serialize and unserialize to store as BSON Binary

PSR-16 incompatible packers

The JsonPacker does not fully comply with PSR-16, as packing and unpacking an object will probably not result in an object of the same class., (*30)

The NopPacker is intended when caching string data only (like HTML output) or if the caching backend supports structured data. Using it when storing objects will might give unexpected results., (*31)

Contributors

Daniel González Twitter: @desarrolla2\ Arnold Daniels Twitter: @ArnoldDaniels, (*32)

The Versions

26/06 2018

dev-master

9999999-dev https://github.com/desarrolla2/Cache/

Provides an cache interface for several adapters Apc, Apcu, File, Mongo, Memcache, Memcached, Mysql, Mongo, Redis is supported.

  Sources   Download

MIT

The Requires

 

The Development Requires

file cache redis memcache apc memcached mysql mongo apcu psr-16 simple-cache

23/06 2018

3.x-dev

3.9999999.9999999.9999999-dev https://github.com/desarrolla2/Cache/

Provides an cache interface for several adapters Apc, Apcu, File, Mongo, Memcache, Memcached, Mysql, Mongo, Redis is supported.

  Sources   Download

MIT

The Requires

 

The Development Requires

file cache redis memcache apc memcached mysql mongo apcu psr-16 simple-cache

23/06 2018

v3.0.0-beta1

3.0.0.0-beta1 https://github.com/desarrolla2/Cache/

Provides an cache interface for several adapters Apc, Apcu, File, Mongo, Memcache, Memcached, Mysql, Mongo, Redis is supported.

  Sources   Download

MIT

The Requires

 

The Development Requires

file cache redis memcache apc memcached mysql mongo apcu psr-16 simple-cache

13/06 2018

dev-psr-16

dev-psr-16 https://github.com/desarrolla2/Cache/

Provides an cache interface for several adapters Apc, Apcu, File, Mongo, Memcache, Memcached, Mysql, Mongo, Redis is supported.

  Sources   Download

MIT

The Requires

 

The Development Requires

file cache redis memcache apc memcached mysql mongo apcu psr-16 simple-cache

27/05 2018

v2.x-dev

2.9999999.9999999.9999999-dev https://github.com/desarrolla2/Cache/

Provides an cache interface for several adapters Apc, Apcu, File, Mongo, Memcache, Memcached, Mysql, Mongo, Redis is supported. New adapters is comming!

  Sources   Download

MIT

The Requires

  • php >=5.4.0

 

The Development Requires

file cache redis memcache apc memcached mysql mongo apcu

04/04 2017

1.8.3

1.8.3.0 https://github.com/desarrolla2/Cache/

Provides an cache interface for several adapters Apc, Apcu, File, Mongo, Memcache, Memcached, Mysql, Mongo, Redis is supported. New adapters is comming!

  Sources   Download

MIT

The Requires

  • php >=5.4.0

 

The Development Requires

file cache redis memcache apc memcached mysql mongo apcu

24/02 2017

1.8.x-dev

1.8.9999999.9999999-dev https://github.com/desarrolla2/Cache/

Provides an cache interface for several adapters Apc, Apcu, File, Mongo, Memcache, Memcached, Mysql, Mongo, Redis is supported. New adapters is comming!

  Sources   Download

MIT

The Requires

  • php >=5.3.3

 

The Development Requires

file cache redis memcache apc memcached mysql mongo apcu

24/02 2017

v1.8.2

1.8.2.0 https://github.com/desarrolla2/Cache/

Provides an cache interface for several adapters Apc, Apcu, File, Mongo, Memcache, Memcached, Mysql, Mongo, Redis is supported. New adapters is comming!

  Sources   Download

MIT

The Requires

  • php >=5.3.3

 

The Development Requires

file cache redis memcache apc memcached mysql mongo apcu

18/01 2017

v2.1.1

2.1.1.0 https://github.com/desarrolla2/Cache/

Provides an cache interface for several adapters Apc, Apcu, File, Mongo, Memcache, Memcached, Mysql, Mongo, Redis is supported. New adapters is comming!

  Sources   Download

MIT

The Requires

  • php >=5.4.0

 

The Development Requires

file cache redis memcache apc memcached mysql mongo apcu

26/11 2015

v2.1.0

2.1.0.0 https://github.com/desarrolla2/Cache/

Provides an cache interface for several adapters Apc, Apcu, File, Mongo, Memcache, Memcached, Mysql, Mongo, Redis is supported. New adapters is comming!

  Sources   Download

MIT

The Requires

  • php >=5.4.0

 

The Development Requires

file cache redis memcache apc memcached mysql mongo apcu

27/10 2015

v2.0.0

2.0.0.0 https://github.com/desarrolla2/Cache/

Provides an cache interface for several adapters Apc, Apcu, File, Mongo, Memcache, Memcached, Mysql, Mongo, Redis is supported. New adapters is comming!

  Sources   Download

MIT

The Requires

  • php >=5.4.0

 

The Development Requires

file cache redis memcache apc memcached mysql mongo apcu

27/10 2015

dev-coveralls

dev-coveralls https://github.com/desarrolla2/Cache/

Provides an cache interface for several adapters Apc, Apcu, File, Mongo, Memcache, Memcached, Mysql, Mongo, Redis is supported. New adapters is comming!

  Sources   Download

MIT

The Requires

  • php >=5.4.0

 

The Development Requires

file cache redis memcache apc memcached mysql mongo apcu

27/10 2015

dev-scrutinizer

dev-scrutinizer https://github.com/desarrolla2/Cache/

Provides an cache interface for several adapters Apc, Apcu, File, Mongo, Memcache, Memcached, Mysql, Mongo, Redis is supported. New adapters is comming!

  Sources   Download

MIT

The Requires

  • php >=5.4.0

 

The Development Requires

file cache redis memcache apc memcached mysql mongo apcu

22/10 2015

1.8.1

1.8.1.0 https://github.com/desarrolla2/Cache/

Provides an cache interface for several adapters Apc, Apcu, File, Mongo, Memcache, Memcached, Mysql, Mongo, Redis is supported. New adapters is comming!

  Sources   Download

MIT

The Requires

  • php >=5.3.3

 

The Development Requires

file cache redis memcache apc memcached mysql mongo apcu

06/11 2014

v1.8.0

1.8.0.0 https://github.com/desarrolla2/Cache/blob/master/README.md

Provides an cache interface for several adapters (Apc, File, Mongo, Memcached, Mysql, ... )

  Sources   Download

MIT

The Requires

  • php >=5.3.0

 

The Development Requires

file cache redis apc memcached mysql mongo

06/11 2014

v1.7.1

1.7.1.0 https://github.com/desarrolla2/Cache/blob/master/README.md

Provides an cache interface for several adapters (Apc, File, Mongo, Memcached, Mysql, ... )

  Sources   Download

MIT

The Requires

  • php >=5.3.0

 

The Development Requires

file cache redis apc memcached mysql mongo

07/10 2013

v1.7.0

1.7.0.0 https://github.com/desarrolla2/Cache/blob/master/README.md

Provides an cache interface for several adapters (Apc, File, Mongo, Memcached, Mysql, ... )

  Sources   Download

MIT

The Requires

  • php >=5.3.0

 

The Development Requires

file cache redis apc memcached mysql mongo

10/07 2013

v1.6.0

1.6.0.0 https://github.com/desarrolla2/Cache/blob/master/README.md

Provides an cache interface for several adapters (Apc, File, Mongo, Memcached, Mysql, ... )

  Sources   Download

MIT

The Requires

  • php >=5.3.0

 

The Development Requires

file cache redis apc memcached mysql mongo

30/06 2013

v1.5.0

1.5.0.0 https://github.com/desarrolla2/Cache/blob/master/README.md

Provides an cache interface for several adapters (Apc, File, Mongo, Memcached, Mysql, ... )

  Sources   Download

MIT

The Requires

  • php >=5.3.0

 

The Development Requires

file cache redis apc memcached mysql mongo

30/06 2013

v1.4.0

1.4.0.0 https://github.com/desarrolla2/Cache/blob/master/README.md

Provides an cache interface for several adapters (Apc, File, Mongo, Memcached, Mysql, ... )

  Sources   Download

MIT

The Requires

  • php >=5.3.0

 

The Development Requires

file cache redis apc memcached mysql mongo

26/04 2013

v1.3.1

1.3.1.0 https://github.com/desarrolla2/Cache/blob/master/README.md

Provides an cache interface for several adapters (Apc, File, Mongo, Memcached, Mysql, ... )

  Sources   Download

MIT

The Requires

  • php >=5.3.0

 

The Development Requires

file cache redis apc memcached mysql mongo

25/04 2013

v1.3.0

1.3.0.0 https://github.com/desarrolla2/Cache/blob/master/README.md

Provides an cache interface for several adapters (Apc, File, Mongo, Memcached, Mysql, ... )

  Sources   Download

MIT

The Requires

  • php >=5.3.0

 

The Development Requires

file cache redis apc memcached mysql mongo

24/04 2013

v1.2.0

1.2.0.0 https://github.com/desarrolla2/Cache/blob/master/README.md

Provides an cache interface for several adapters (Apc, File, Mongo, Memcached, Mysql, ... )

  Sources   Download

MIT

The Requires

  • php >=5.3.0

 

The Development Requires

file cache redis apc memcached mysql mongo

25/11 2012

v1.1.0

1.1.0.0 https://github.com/desarrolla2/Cache/blob/master/README.md

Provides an cache interface for several adapters (Apc, File, Mongo, Memcached, Mysql, ... )

  Sources   Download

MIT

The Requires

  • php >=5.3.0

 

file cache redis apc memcached mysql mongo

24/10 2012

v1.0.0

1.0.0.0 https://github.com/desarrolla2/Cache

Provides an cache interface for several adapters (Apc, File, Mencached, Mysql, ... )

  Sources   Download

MIT

The Requires

  • php >=5.3.0

 

cache apc memcached mysql cache file cache