$r = new Redis();
$r->connect('127.0.0.1', 6379);
$r->set('my_key', 'hello');
$r->get('my_key');
new Redis()
- create Redis objectconnect(
- connect to specified host and port127.0.0.1
- Redis host IP6379
- Redis port to connect toset
- save string value to the specified Redis keymy_key
- name of the keyget
- get string key value
<?php
$r = new Redis();
$r->connect('127.0.0.1', 6379);
$r->set('my_key', 'hello');
echo $r->get('my_key');
hello