drsdre/yii2-redis-counter 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

drsdre/yii2-redis-counter

Composer 安装命令:

composer require drsdre/yii2-redis-counter

包简介

Redis Counter implements fast atomic counters using Redis storage.

README 文档

README

Redis Counter implements fast atomic counters using Redis storage.

Installation

The preferred way to install this extension is through composer.

Either run

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

or add

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

to the require section of your composer.json file.

Usage

You need to setup the client as application component:

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

Optional the parameter 'redis' can be added to specify a specific Redis connection.

Usage

Once the extension is installed, use it in your code like :

    // 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);
    }

统计信息

  • 总下载量: 17.7k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 2
  • 点击次数: 3
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 2
  • Watchers: 1
  • Forks: 1
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2016-01-16

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固