sw-fw-less
  • sw-fw-less
  • get started
    • Installation
    • Directory
    • Config
    • Quick Start
  • MVC
    • Router
    • Middleware
    • Request
    • Param Validator
    • Model
    • Response
  • Database
    • MySQL
    • Redis
    • Elasticsearch
  • Storage
    • General
    • File
    • Qiniu
    • Alioss
  • OTHER
    • Pagination
    • Helper
    • Error Handler
    • AMQP-0-9-1
    • Events
  • Deployment
    • Nginx
    • Docker
  • APPENDIX
    • Development Rules
Powered by GitBook
On this page

Was this helpful?

  1. Database

Redis

PreviousMySQLNextElasticsearch

Last updated 6 years ago

Was this helpful?

Example

// Pick a resource from pool manually
$key = $this->redisPool->getKey($originKey);
/** @var \Redis $redis */
$redis = $this->redisPool->pick();
try {
    $redis->set('foo', 'bar');
} catch (\Exception $e) {
    throw $e;
} finally {
    $this->redisPool->release($redis);
}

// Use php stream
unlink('redis://foo'); // del foo
file_put_contents('redis://foo', 'bar'); // set foo bar
file_get_contents('redis://foo') // get foo

For detailed usage, please see .

document