2017 © Pedro Peláez
 

yii2-extension yii2-redis-counter

Redis Counter implements fast atomic counters using Redis storage.

image

drsdre/yii2-redis-counter

Redis Counter implements fast atomic counters using Redis storage.

  • Saturday, January 16, 2016
  • by drsdre
  • Repository
  • 1 Watchers
  • 3 Stars
  • 1,570 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 1 Forks
  • 0 Open issues
  • 3 Versions
  • 10 % Grown

The README.md

Yii2 Redis Counter

Redis Counter implements fast atomic counters using Redis storage., (*1)

Installation

The preferred way to install this extension is through composer., (*2)

Either run, (*3)

php composer.phar require --prefer-dist drsdre/yii2-redis-counter "*"

or add, (*4)

"drsdre/yii2-redis-counter": "*"

to the require section of your composer.json file., (*5)

Usage

You need to setup the client as application component:, (*6)

'components' => [
    'redisCounter' => [
        'class' => 'drsdre\redis\Counter',
    ],
    ...
]

Optional the parameter 'redis' can be added to specify a specific Redis connection., (*7)

Usage

Once the extension is installed, use it in your code like :, (*8)

    // Create a hourly counter
    $counter_key = 'hourly_statistics';

    // Check if counter is setup
    if (Yii::$app->redisCounter->exists($counter_key)) {
        // Atomic increment counter with 1
        Yii::$app->redisCounter->incr($counter_key);
    } else {
        // Create counter set value to 1 and let it exist for 1 hour
        Yii::$app->redisCounter->set($counter_key, 1, 60*60);
    }

The Versions

16/01 2016

dev-master

9999999-dev

Redis Counter implements fast atomic counters using Redis storage.

  Sources   Download

MIT

The Requires

 

by A.F.Schuurman

extension yii2 redis counter atomic

16/01 2016

0.2

0.2.0.0

Redis Counter implements fast atomic counters using Redis storage.

  Sources   Download

MIT

The Requires

 

by A.F.Schuurman

extension yii2 redis counter atomic

16/01 2016

1.0

1.0.0.0

Redis Counter implements fast atomic counters using Redis storage.

  Sources   Download

MIT

The Requires

 

by A.F.Schuurman

extension yii2 redis counter atomic