https://github.com/xutl/yii2-ranking
redis ranks
https://github.com/xutl/yii2-ranking
rankings redis yii2
Last synced: 2 months ago
JSON representation
redis ranks
- Host: GitHub
- URL: https://github.com/xutl/yii2-ranking
- Owner: xutl
- License: gpl-3.0
- Created: 2017-04-05T05:55:33.000Z (about 8 years ago)
- Default Branch: master
- Last Pushed: 2017-04-06T02:14:13.000Z (about 8 years ago)
- Last Synced: 2025-01-20T12:46:37.309Z (4 months ago)
- Topics: rankings, redis, yii2
- Language: PHP
- Size: 26.4 KB
- Stars: 1
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# yii2-ranks
redis ranks
Installation
------------The preferred way to install this extension is through [composer](http://getcomposer.org/download/).
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:
```php
return [
//....
'components' => [
'ranking' => [
'class' => 'xutl\ranking\Client',
'redis' => [
'scheme' => 'tcp',
'host' => '127.0.0.1',
'port' => 6379,
//'password' => '1984111a',
'db' => 0
],
],
]
];
```使用
----```php
/** @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;
```