This package is abandoned and no longer maintained. No replacement package was suggested.

PHP singleton for Memcached/Redis

1.2.0 2015-10-28 17:04 UTC

This package is not auto-updated.

Last update: 2021-10-02 02:07:52 UTC


README

PHP singleton for Memcached/Redis

Latest Stable Version License

Requirements

  • PHP >= 5.3

Suggestions

  • PHP Memcached extension
  • PHP Redis extension

Installation

Install directly via Composer:

$ composer require starter-kit/cache

Basic Usage

Memcached

<?php

// Require your autoloading script (Composer autoload here) to use namespaces
require_once 'vendor/autoload.php';

use StarterKit\Cache\Memcached;

// First instanciation : pass your Memcached parameters
$mc = Memcached::getInstance('YOUR_SERVER_NAME', 'YOUR_SERVER_PORT');

// Later in your code : you can retrieve your instance at any time, without creating new Memcached connection
$res = Memcached::getInstance()->set('yolo', 'swag');

Redis

<?php

// Require your autoloading script (Composer autoload here) to use namespaces
require_once 'vendor/autoload.php';

use StarterKit\Cache\Redis;

// First instanciation : pass your Redis parameters
$mc = Redis::getInstance('YOUR_SERVER_NAME', 'YOUR_SERVER_PORT');

// Later in your code : you can retrieve your instance at any time, without creating new Redis connection
$res = Redis::getInstance()->set('yolo', 'swag');