yuzuru-s/redis-ranking
Composer 安装命令:
composer require yuzuru-s/redis-ranking
包简介
Wrapping Redis's sorted set APIs for specializing ranking operations.
README 文档
README
Abstracting Redis's Sorted Set APIs and PHP to use as a ranking system.
Requirements
- Redis
-
=2.4
-
- PhpRedis extension
- PHP
-
=5.5 >=5.6, >=7.0
-
- Composer
Installation
- Using composer
{
"require": {
"yuzuru-s/redis-ranking": "1.0.*"
}
}
$ php composer.phar update yuzuru-s/redis-ranking --dev
How to use
Please check sample code
<?php require __DIR__ . '/../vendor/autoload.php'; use 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" } */
How to run unit test
Run with default setting.
% vendor/bin/phpunit -c phpunit.xml.dist
Currently tested with PHP 7.0.0 + Redis 2.6.12.
History
- 1.0.2
- Bug fix
- 1.0.0
- Published
License
Copyright (c) 2016 YUZURU SUZUKI. See MIT-LICENSE for further details.
Copyright
- Yuzuru Suzuki
统计信息
- 总下载量: 283
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 6
- 点击次数: 1
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2016-11-28