2017 © Pedro Peláez
 

library rw-file-cache

RW File Cache is a PHP File-based Caching Library. Its syntax is designed to closely resemble the PHP memcache extension.

image

rapidwebltd/rw-file-cache

RW File Cache is a PHP File-based Caching Library. Its syntax is designed to closely resemble the PHP memcache extension.

  • Thursday, March 1, 2018
  • by DivineOmega
  • Repository
  • 4 Watchers
  • 5 Stars
  • 59,290 Installations
  • PHP
  • 7 Dependents
  • 0 Suggesters
  • 2 Forks
  • 1 Open issues
  • 15 Versions
  • 28 % Grown

The README.md

RW File Cache

Build Status Coverage Status StyleCI Packagist, (*1)

RW File Cache is a PHP File-based Caching Library., (*2)

Its syntax is designed to closely resemble the PHP memcache extension., (*3)

Installation

You can easily install with composer. Just run composer require rapidwebltd/rw-file-cache., (*4)

If you are using Laravel, consider using the Laravel Cache Driver for RW File Cache instead., (*5)

Usage

This section will show you how to use RW File Cache. If you have used memcache before, this should be pretty familiar., (*6)

Setup & Configuration

Before you can do anything with RW File Cache, you must instantiate it and then, if you wish, set some configuration options., (*7)

require_once "vendor/autoload.php";

$cache = new \rapidweb\RWFileCache\RWFileCache();

$cache->changeConfig(["cacheDirectory" => "/tmp/rwFileCacheStorage/"]);

This code creates a new RW File Cache object called $cache and then configures it to store its cache files in the /tmp/rwFileCacheStorage/ directory., (*8)

There are several different configuration variables you can override. The table below describes them., (*9)

Option Description Default
cacheDirectory The directory in which you wish the cache files to be stored. We recommend you change this to a site-specific directory and ensure it is outside of the web root. You must include a trailing slash. /tmp/rwFileCacheStorage/
gzipCompression Whether or not to compress cache files using gzip. Unless you are storing very small values in your cache files, we recommend you leave this enabled. true
fileExtension The file extension that will be appended to all your cache files. cache
unixLoadUpperThreshold If your server's load is greater than this value, cache files will be returned regardless of whether they have expired. This can be used to prevent cache files being regenerated when server load is high. If you do not wish to use this feature, set this option to -1. 4.00

Setting a cache item

Putting something in your file cache is easy. You just need to use the set method, as shown below., (*10)

$cache->set('nursery_rhyme',"Mary had a little lamb", strtotime('+ 1 day'));

The first parameter is the cache key, which uniquely references this cache item., (*11)

The second parameter is the cache value - what you wish to store in this cache item. This can be a string, integer, array, object or any type of serializable PHP variable., (*12)

The third paramter is the expiry time. It can be specified as a UNIX timestamp or as a number of seconds less than 30 days worth. Cache items will expire and not be retrievable when this time is reached., (*13)

Note that if you use dots, dashes, underscores or a few other special characters in your cache key, the created cache files will be put into a directory structure. For example, a cache key of objects.cars.redCar will be stored in objects/cars/redCar.cache. This is useful if you wish to categorise cache files and to prevent too many cache files building up in a single directory., (*14)

Getting a cache item

To get a cache item you've previously stored, you need to use the get method. An example of how to do this is shown below., (*15)

$var = $cache->get('nursery_rhyme');

The only parameter is the cache key you defined when setting the cache item. You can retrieve any cached variable in this way., (*16)

Other RW File Cache methods

The setting and retrieval of cache items are the most important parts of RW File Cache. In fact, the set and get methods are probably all you will need., (*17)

However, the library provides the following more advanced commands if you need them., (*18)

  • $cache->delete($key) - Delete a specific item from the cache.
  • $cache->flush() - Deletes all items from the cache.
  • $cache->replace($key, $content, $expiry) - Similar to the set method, but will only update a cache item's value if the cache item already exists.
  • $cache->increment($key, $offset) - Increment a numeric cache item value by the specified offset (or one if the offset is omitted).
  • $cache->decrement($key, $offset) - Decrements a numeric cache item value by the specified offset (or one if the offset is omitted).

The Versions

01/03 2018

dev-master

9999999-dev https://github.com/rapidwebltd/RW-File-Cache

RW File Cache is a PHP File-based Caching Library. Its syntax is designed to closely resemble the PHP memcache extension.

  Sources   Download

LGPL3 LGPL-3.0-only

The Requires

  • php >=5.2.1

 

The Development Requires

cache php library caching file cache caching library

01/03 2018

dev-analysis-zepRvP

dev-analysis-zepRvP https://github.com/rapidwebltd/RW-File-Cache

RW File Cache is a PHP File-based Caching Library. Its syntax is designed to closely resemble the PHP memcache extension.

  Sources   Download

LGPL-3.0-only

The Requires

  • php >=5.2.1

 

The Development Requires

cache php library caching file cache caching library

23/01 2018

v1.2.5

1.2.5.0 https://github.com/rapidwebltd/RW-File-Cache

RW File Cache is a PHP File-based Caching Library. Its syntax is designed to closely resemble the PHP memcache extension.

  Sources   Download

LGPL-3.0-only

The Requires

  • php >=5.2.1

 

The Development Requires

cache php library caching file cache caching library

23/01 2018

v1.2.4

1.2.4.0 https://github.com/rapidwebltd/RW-File-Cache

RW File Cache is a PHP File-based Caching Library. Its syntax is designed to closely resemble the PHP memcache extension.

  Sources   Download

LGPL-3.0-only

The Requires

  • php >=5.2.1

 

The Development Requires

cache php library caching file cache caching library

11/01 2018

v1.2.3

1.2.3.0 https://github.com/rapidwebltd/RW-File-Cache

RW File Cache is a PHP File-based Caching Library. Its syntax is designed to closely resemble the PHP memcache extension.

  Sources   Download

LGPL3

The Requires

  • php >=5.2.1

 

The Development Requires

cache php library caching file cache caching library

11/01 2018

v1.2.2

1.2.2.0 https://github.com/rapidwebltd/RW-File-Cache

RW File Cache is a PHP File-based Caching Library. Its syntax is designed to closely resemble the PHP memcache extension.

  Sources   Download

LGPL3

The Requires

  • php >=5.2.1

 

The Development Requires

cache php library caching file cache caching library

05/01 2018

v1.2.1

1.2.1.0 https://github.com/rapidwebltd/RW-File-Cache

RW File Cache is a PHP File-based Caching Library. Its syntax is designed to closely resemble the PHP memcache extension.

  Sources   Download

LGPL3

The Requires

  • php >=5.2.1

 

The Development Requires

cache php library caching file cache caching library

04/01 2018

v1.2.0

1.2.0.0 https://github.com/rapidwebltd/RW-File-Cache

RW File Cache is a PHP File-based Caching Library. Its syntax is designed to closely resemble the PHP memcache extension.

  Sources   Download

LGPL3

The Requires

 

cache php library caching file cache caching library

28/12 2017

v1.1.0

1.1.0.0 https://github.com/rapidwebltd/RW-File-Cache

RW File Cache is a PHP File-based Caching Library. Its syntax is designed to closely resemble the PHP memcache extension.

  Sources   Download

LGPL3

The Requires

 

cache php library caching file cache caching library

28/12 2017

v2.0.0

2.0.0.0 https://github.com/rapidwebltd/RW-File-Cache

RW File Cache is a PHP File-based Caching Library. Its syntax is designed to closely resemble the PHP memcache extension.

  Sources   Download

LGPL3

The Requires

 

cache php library caching file cache caching library

07/07 2017

v1.0.4

1.0.4.0 https://github.com/rapidwebltd/RW-File-Cache

PHP File-based Caching Library

  Sources   Download

LGPL3

The Requires

 

cache php library caching file cache caching library

13/03 2017

v1.0.3

1.0.3.0 https://github.com/rapidwebltd/RW-File-Cache

PHP File-based Caching Library

  Sources   Download

LGPL3

The Requires

  • php >=5.2.1

 

cache php library caching file cache caching library

13/03 2017

v1.0.2

1.0.2.0 https://github.com/rapidwebltd/RW-File-Cache

PHP File-based Caching Library

  Sources   Download

LGPL3

The Requires

  • php >=5.2.1

 

cache php library caching file cache caching library

13/03 2017

v1.0.1

1.0.1.0 https://github.com/rapidwebltd/RW-File-Cache

PHP File-based Caching Library

  Sources   Download

LGPL3

The Requires

  • php >=5.2.1

 

cache php library caching file cache caching library

20/02 2017

v1.0

1.0.0.0 https://github.com/rapidwebltd/RW-File-Cache

PHP File-based Caching Library

  Sources   Download

LGPL3

The Requires

  • php >=5.2.1

 

cache php library caching file cache caching library