2017 © Pedro Peláez
 

library redis-ranking

Wrapping Redis's sorted set APIs for specializing ranking operations.

image

yuzuru-s/redis-ranking

Wrapping Redis's sorted set APIs for specializing ranking operations.

  • Monday, November 28, 2016
  • by s1130125
  • Repository
  • 1 Watchers
  • 5 Stars
  • 143 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 4 Versions
  • 0 % Grown

The README.md

Simple Ranking library for Redis and PHP

Coverage Status Build Status Stable Version Download Count License, (*1)

Abstracting Redis's Sorted Set APIs and PHP to use as a ranking system., (*2)

Requirements

  • Redis
    • >=2.4
  • PhpRedis extension
    • https://github.com/nicolasff/phpredis
  • 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, (*3)

<?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., (*4)

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

Currently tested with PHP 7.0.0 + Redis 2.6.12., (*5)

History

  • 1.0.2
    • Bug fix
  • 1.0.0
    • Published

License

Copyright (c) 2016 YUZURU SUZUKI. See MIT-LICENSE for further details., (*6)

  • Yuzuru Suzuki
    • http://yuzurus.hatenablog.jp/

The Versions

28/11 2016

dev-master

9999999-dev https://github.com/YuzuruS/redis-ranking

Wrapping Redis's sorted set APIs for specializing ranking operations.

  Sources   Download

MIT

The Requires

  • php >=5.5.0

 

The Development Requires

redis ranking sorted set page view

28/11 2016

1.0.2

1.0.2.0 https://github.com/YuzuruS/redis-ranking

Wrapping Redis's sorted set APIs for specializing ranking operations.

  Sources   Download

MIT

The Requires

  • php >=5.5.0

 

The Development Requires

redis ranking sorted set page view

28/11 2016

1.0.1

1.0.1.0 https://github.com/YuzuruS/redis-ranking

Wrapping Redis's sorted set APIs for specializing ranking operations.

  Sources   Download

MIT

The Requires

  • php >=5.5.0

 

The Development Requires

redis ranking sorted set page view

28/11 2016

1.0.0

1.0.0.0 https://github.com/YuzuruS/redis-ranking

Wrapping Redis's sorted set APIs for specializing ranking operations.

  Sources   Download

MIT

The Requires

  • php >=5.5.0

 

The Development Requires

redis ranking sorted set page view