提供
- CounterRank 基础完备的排名功能 | functions rank
- DateRank 时间纬度排名功能 | date rank
- MutliRank 多排名交并功能 | rank union
- PagerRank分页排名功能 | pager rank
v1.0.0.3
- 更新
carbon
包
v1.0.0.2
- 提供分页排名功能排名功能
- 完善文档
v1.0.0.1
- 提供多排名交并功能
- 重构代码
v1.0.0.0
- 提供时间维度排名功能
- 修复遗留bug
composer require jue/rank
CounterRank : testExample
DateRank: testExample
MutliRank:testExample
PagerRank:testExample
所有其他排名组件都基于CounterRank,Counter提供最完备的排名功能,任何Cache只要实现IRedis
的方法即可使用CounterRank,默认使用\Redis
.
$rank = new CounterRank($redis,'activity','test');//新建一个counterRank
var_dump($rank->getRankKey());
//结果: activity:test
$rank->addRankField(1, 2);
var_dump($rank->getRankScore(1));
//结果: 2
$rank = new DateRank($redis,'activity','test', Carbon::now());
var_dump("rankKey:".$rank->getRankKey());
//结果:
activity:test:2017-03-31
$rank1 = new DateRank($redis,'activity','test', Carbon::now());
$rank2 = new DateRank($redis,'activity','test', Carbon::tomorrow());
$rank1->addRankField(1,2);
$rank1->addRankField(2,4);
$rank2->addRankField(1,2);
$mutliRank = new MutliCounterRank([$rank1,$rank2], $redis);
$rank = new CounterRank($redis, 'activity', 'pager');
$rank->batchAddRankField([
1 => 2,
2 => 4,
3 => 3,
4 => 20,
5 => 7,
6 => 13,
7 => 10,
8 => 13,
9 => 9
]);
$pager = new PagerRank($rank,5,2);