Skip to content

Latest commit

 

History

History
34 lines (25 loc) · 570 Bytes

redis-simple-example.md

File metadata and controls

34 lines (25 loc) · 570 Bytes

Redis simple example

$r = new Redis(); 
$r->connect('127.0.0.1', 6379);

$r->set('my_key', 'hello');

$r->get('my_key');
  • new Redis() - create Redis object
  • connect( - connect to specified host and port
  • 127.0.0.1 - Redis host IP
  • 6379 - Redis port to connect to
  • set - save string value to the specified Redis key
  • my_key - name of the key
  • get - get string key value

Example:

<?php

$r = new Redis(); 
$r->connect('127.0.0.1', 6379); 

$r->set('my_key', 'hello');

echo $r->get('my_key');
hello