1. Go to this page and download the library: Download yuzuru-s/redis-ranking 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/ */
yuzuru-s / redis-ranking example snippets
YuzuruS\Redis\Ranking;
$redis = new \Redis();
$redis->connect('127.0.0.1', 6379);
$ranking = new Ranking($redis);
$article_ids_of_accessed = [1,1,2,3,4,5,3,4,5,1];
// count up pv of access ids
foreach ($article_ids_of_accessed as $a) {
$ranking->cntUpPv($a);
}
// make ranking
$ranking->makeAccessRanking(1);
// get ranking
var_dump($ranking->getAccessRanking(1));
/**
array(5) {
[0] =>
string(1) "1"
[1] =>
string(1) "5"
[2] =>
string(1) "4"
[3] =>
string(1) "3"
[4] =>
string(1) "2"
}
*/
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.