starter-kit / cache
PHP singleton for Memcached/Redis
Installs: 3 048
Dependents: 1
Suggesters: 0
Security: 0
Stars: 4
Watchers: 2
Forks: 1
Open Issues: 0
Requires
- php: >=5.3
Suggests
- ext-memcached: PHP Memcached extension
- ext-redis: PHP Redis extension
This package is not auto-updated.
Last update: 2021-10-02 02:07:52 UTC
README
PHP singleton for Memcached/Redis
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');