2017 © Pedro Peláez
 

library cache

Dual-way Redis cache management

image

aloframework/cache

Dual-way Redis cache management

  • Monday, November 7, 2016
  • by Alorel
  • Repository
  • 1 Watchers
  • 0 Stars
  • 25 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 7 Versions
  • 0 % Grown

The README.md

AloFramework | Cache

Redis cache manager, (*1)

Latest release API documentation: https://aloframework.github.io/cache/, (*2)

License Latest Stable Version Total Downloads, (*3)

dev-develop Latest release
Dev Build Status Release Build Status
Coverage Status Coverage Status

Installation

Installation is available via Composer:, (*4)

composer require aloframework/cache

Usage

Only Redis is supported at this time., (*5)

<?php

    use AloFramework\Cache\Clients\RedisClient;

    $redis = new RedisClient();
    $redis->connect('localhost');

    $redis->setKey('foo', 'bar', 300); // expire the key in 5 minutes
    $redis->setKey('foo', 'bar', new DateTime('2015-01-01 05:05:05')); //Expire the key on 2015-01-01 05:05:05
    $redis->setKey('foo', 'bar'); //Use default expiration time
    $redis['foo'] = 'bar'; //Use default expiration time

    //Echo the keys
    echo $redis->getKey('foo');
    echo $redis['foo'];

    //Echo all the keys
    print_r($redis->getAll());

    //Loop through all the keys
    foreach ($redis as $k => $v) {
        echo 'Key: ' . $k . ', Value: ' . $v . '<br/>';
    }

    //Count the number of items in the database
    echo count($redis);

    //Or do anything you would with the standard Redis class - RedisClient extends it.

Alternative usage

<?php

    use AloFramework\Cache\Clients\RedisClient;
    use AloFramework\Cache\CacheItem;

    //Save an item
    $server = new RedisClient();
    $server->connect();

    $cacheItem           = new CacheItem('key', 'value', $server);
    $cacheItem->lifetime = 600;
    $cacheItem->saveToServer();

    // Get or load an item
    $cacheItem = new CacheItem('key');
    $cacheItem->getFromServer($server);

    echo $cacheItem->value;

Configuration

Configuration is done via the Configuration class., (*6)

  • Cfg::CFG_IP - default IP to use in the connect() method (defaults to 127.0.0.1)
  • Cfg::CFG_PORT - default port to use in the connect() method (defaults to 6379)
  • Cfg::CFG_TIMEOUT - default cache timeout (defaults to 300 seconds)

The Versions

07/11 2016

dev-master

9999999-dev https://github.com/aloframework/cache

Dual-way Redis cache management

  Sources   Download

Apache-2.0

The Requires

 

The Development Requires

cache php redis 5.5 aloframework

07/11 2016

dev-develop

dev-develop https://github.com/aloframework/cache

Dual-way Redis cache management

  Sources   Download

Apache-2.0

The Requires

 

The Development Requires

cache php redis 5.5 aloframework

07/11 2016

2.0

2.0.0.0 https://github.com/aloframework/cache

Dual-way Redis cache management

  Sources   Download

Apache-2.0

The Requires

 

The Development Requires

cache php redis 5.5 aloframework

19/11 2015

1.0.2

1.0.2.0 https://github.com/aloframework/cache

Dual-way Redis cache management

  Sources   Download

GPL-3.0+

The Requires

 

The Development Requires

cache php redis 5.5 aloframework

31/10 2015

1.0.1

1.0.1.0 https://github.com/aloframework/cache

Dual-way Redis cache management

  Sources   Download

GPL-3.0+

The Requires

 

The Development Requires

cache php redis 5.4 aloframework

30/10 2015

1.0

1.0.0.0 https://github.com/aloframework/cache

Dual-way Redis cache management

  Sources   Download

GPL-3.0+

The Requires

 

The Development Requires

cache php redis 5.4 aloframework

25/10 2015

0.1

0.1.0.0 https://github.com/aloframework/cache

Common elements of AloFramework

  Sources   Download

GPL-3.0+

The Requires

 

The Development Requires

cache php redis 5.4 aloframework