starter-kit / cache
此包已被废弃且不再维护。未建议替代包。
PHP 单例模式用于Memcached/Redis
1.2.0
2015-10-28 17:04 UTC
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 单例模式用于Memcached/Redis
要求
- PHP >= 5.3
建议
- PHP Memcached 扩展
- PHP Redis 扩展
安装
通过 Composer 直接安装
$ composer require starter-kit/cache
基本用法
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');