PHP code example of mp3000mp / redis-client
1. Go to this page and download the library: Download mp3000mp/redis-client library. Choose the download type require. 2. Extract the ZIP file and open the index.php. 3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
mp3000mp / redis-client example snippets
// This will try to connect and throw a RedisClientException if connection failed
$client = new RedisClient($host, $port, $auth);
// simple get set system
$client->set('key', 'value');
$val = $client->get('key');
// this value will be converted into json text into redis
$client->set('key_array', ['test' => 'test']);
// returns '{"test":"test"}'
$client->get('key_array');
// returns ['test' => 'test']
$client->get('key_array', true);
// this key will live 120 seconds
$client->set('key', 'test', 120);
$client->delete('key');
// close connection
$client->close();