Skip to content
This repository has been archived by the owner on Sep 29, 2021. It is now read-only.

Sicaa/starter-kit-cache

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

starter-kit-cache

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');