Download the PHP package itsoneiota/cache without Composer

On this page you can find all versions of the php package itsoneiota/cache. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package cache

One iota Cache Library

Overview

A simple interface to cache sources.

The Cache class wraps a Memcached instance, adding key and value mapping, and default expiry times.

Installation

The best way to autoload this package and its dependencies is to include the standard Composer autoloader, vendor/autoload.php.

Testing

The library's suite of unit tests can be run by calling vendor/bin/phpunit from the root of the repository.

Basic Usage

use \itsoneiota\cache;

$mc = new \Memcached();
// Configure memcached…

$cache = new Cache($mc);

$cache->set('foo', 'bar'); // Caches a value of 'bar' against the key of 'foo'.
$cache->get('foo'); // Returns 'bar'.

Prefixing Cache Keys

If you wish to avoid cache key collisions, you can initialise your cache with a key prefix, this will be added to all keys when getting, setting and deleting. For example:

use \itsoneiota\cache;

$mc = new \Memcached();
// Configure memcached…

$cache = new Cache($mc, 'myStore');

$cache->set('foo', 'bar'); // Caches a value of 'bar' against the key of 'myStore.foo'.
$cache->get('foo'); // Returns 'bar'.

Default Expiry Times

When creating a cache, you can specify a default time to live that can be used when adding and setting. This can be overridden when adding and setting by specifying an explicit expiry time.

use \itsoneiota\cache;

$mc = new \Memcached();
// Configure memcached…

$cache = new Cache($mc, 'myStore', 120);

$cache->set('foo', 'bar'); // Caches for 2 minutes (the default).
$cache->set('bat', 'baz', 30); // Caches for 30 seconds.

Encrypting Cache Contents

SecureCache is a subclass of Cache that encrypts its contents using two-way encryption.

use \itsoneiota\cache;

$mc = new \Memcached();
// Configure memcached…

$cache = new SecureCache($mc, 'myTopSecretEncryptionKey');

If you need to prefix keys in SecureCache, you can always call $cache->setKeyPrefix('myPrefix').

Bonus Caches (Cacheback)

InMemoryCacheFront

If you're likely to make several calls to a cache within a request, possibly to the same value, InMemoryCacheFront can prevent unnecessary network calls to the Memcached server, by providing a read- and write-through cache on top of a Cache instance. The number of items held in memory is limited to 100 by default, but that can be changed with a constructor argument.

use \itsoneiota\cache;

$mc = new \Memcached();
// Configure memcached…

$cache = new Cache($mc, 'myStore', 120);

$superFastCache = new InMemoryCacheFront($cache, 1000); // Store 1000 items in local memory.

InMemoryCache

If you need to simulate a cache, without a Memcached server, InMemoryCache will do the job. It looks just like a Cache, but it holds everything in a plain-old PHP array.

MockCache

For testing purposes, MockCache simulates a cache, and allows you to check that values have been set, and what their expiry times are, without having to go through all the hassle of using PHPUnit mocks. getExpiration() allows you to check the expiration of a key. timePasses() allows you to simulate the passage of time, advancing by a given number of seconds and expiring cache items accordingly.

use \itsoneiota\cache;

$cache = new MockCache();

$cache->set('foo', 'bar', 60);
$cache->get('foo'); // Returns 'bar'.

$cache->timePasses(61);

$cache->get('foo'); // Returns NULL.

To Do…

Things I might add, soon-ish:


All versions of cache with dependencies

PHP Build Version
Package Version
Requires php Version >=5.5
predis/predis Version ^1.1
itsoneiota/count Version 2.0.2
cheprasov/php-redis-client Version 1.7.2
mockery/mockery Version ^1.2
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package itsoneiota/cache contains the following files

Loading the files please wait ....