xutl / yii2-ranking
The ranks extension for the Yii framework
Installs: 1 320
Dependents: 0
Suggesters: 0
Security: 0
Stars: 1
Watchers: 1
Forks: 1
Open Issues: 0
Type:yii2-extension
Requires
- php: >=5.4.0
- nesbot/carbon: ~1.22
- predis/predis: ~1.0
- yiisoft/yii2: *
This package is auto-updated.
Last update: 2024-11-11 03:11:07 UTC
README
redis ranks
Installation
The preferred way to install this extension is through composer.
Either run
php composer.phar require --prefer-dist xutl/yii2-ranking
or add
"xutl/yii2-ranking": "~1.0.0"
to the require section of your composer.json
file.
配置
To use this extension, you have to configure the Connection class in your application configuration:
return [ //.... 'components' => [ 'ranking' => [ 'class' => 'xutl\ranking\Client', 'redis' => [ 'scheme' => 'tcp', 'host' => '127.0.0.1', 'port' => 6379, //'password' => '1984111a', 'db' => 0 ], ], ] ];
使用
/** @var \xutl\ranking\Ranking $ranking */ $ranking = Yii::$app->ranking->getRankingRef('download'); $ranking->addScores(1, 2); $ranking->addScores(2, 2); $ranking->addScores(2, 2); $ranking->addScores(1, 2); $ranking->addScores(3, 2); $ranking->addScores(3, 2); $ranking->addScores(1, 2); $ranking->addScores(5, 2); $ranking->addScores(6, 2); $ranking->addScores(7, 2); $ranking->addScores(9, 2); $ranking->addScores(1, 2); $ranking->addScores(1, 2); $rankings = $ranking->getCurrentMonthTop10(date('Ymd'), 0, 9); print_r($rankings); exit;