1. Go to this page and download the library: Download codemix/yiiredis 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/ */
$list = new ARedisList("aNameForYourListGoesHere");
$list->add("cats");
$list->add("dogs");
$list->add("fish");
foreach($list as $i => $val) {
echo $val."<br />";
}
$list->clear(); // delete the list
$set = new ARedisSet("aNameForYourSet");
$set->add(1);
$set->add(2);
$set->add(3);
echo $set->count; // outputs 3
$set->add(3);
echo $set->count; // still 3, cannot add the same value more than once
foreach($set as $val) {
echo $val."<br />";
}
$channel = new ARedisChannel("myChan");
$channel->onReceiveMessage = function($redis, $channel, $message) {
echo "Message Received: ".$message."\n";
}
$channel->publish("hello world"); // sends a messsage to the channel
$channel->subscribe(); // subscribes to the channel and listens to messages, blocks the process
$counter = new ARedisCounter("totalPageViews");
$counter->increment();
echo $counter->getValue();
$mutex = new ARedisMutex("someOperation");
$mutex->block(); // blocks execution until the resource becomes available
// do something
$mutex->unlock(); // release the lock
$record = ARedisRecord::model()->findByPk(1); // loads a record with a unique id of 1
$record->name = "a test name"; // sets the name attribute on the record
$record->somethingElse = "some other value";
$record->save(); // saves the record to redis
$record->delete(); // deletes the record from redis
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.