yuzuru-s/redis-ranking

包装Redis的排序集API,用于特定排名操作。

1.0.2 2016-11-28 15:26 UTC

This package is not auto-updated.

Last update: 2024-09-14 19:20:20 UTC


README

Coverage Status Build Status Stable Version Download Count License

抽象Redis的Sorted Set API和PHP,用作排名系统。

要求

安装

  • 使用Composer
{
    "require": {
       "yuzuru-s/redis-ranking": "1.0.*"
    }
}
$ php composer.phar update yuzuru-s/redis-ranking --dev

如何使用

请查看示例代码

<?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"
}
 */

如何运行单元测试

使用默认设置运行。

% vendor/bin/phpunit -c phpunit.xml.dist

当前已测试PHP 7.0.0 + Redis 2.6.12。

历史

  • 1.0.2
    • 错误修复
  • 1.0.0
    • 发布

许可协议

版权 (c) 2016 YUZURU SUZUKI。有关详细信息,请参阅MIT-LICENSE。

版权