Skip to content
This repository was archived by the owner on Aug 15, 2018. It is now read-only.

Commit b5eb7b9

Browse files
committed
Add docs, travis and codeclimate
1 parent 25589cd commit b5eb7b9

File tree

6 files changed

+149
-1
lines changed

6 files changed

+149
-1
lines changed

.codeclimate.yml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
---
2+
engines:
3+
duplication:
4+
enabled: true
5+
config:
6+
languages:
7+
- php
8+
fixme:
9+
enabled: true
10+
phpcodesniffer:
11+
enabled: true
12+
phpmd:
13+
enabled: true
14+
ratings:
15+
paths:
16+
- "**.php"
17+
exclude_paths:
18+
- tests/

.travis.yml

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
language: php
2+
3+
php:
4+
- '5.4'
5+
- '5.5'
6+
- '5.6'
7+
- '7.0'
8+
9+
services:
10+
- redis-server
11+
12+
before_install: echo "extension = redis.so" >> ~/.phpenv/versions/$(phpenv version-name)/etc/php.ini
13+
14+
install:
15+
- composer global require "fxp/composer-asset-plugin:^1.2.0"
16+
- composer require codeclimate/php-test-reporter --dev
17+
- composer install --no-progress --no-interaction
18+
19+
script:
20+
- ./vendor/bin/phpunit --coverage-clover build/logs/clover.xml
21+
22+
addons:
23+
code_climate:
24+
repo_token: 255db28eb13c47dff54362135d879145fc97afff3eb91d97158608818bb4d1a9
25+
26+
after_script:
27+
- vendor/bin/test-reporter

README.md

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,14 @@ This extension provides the [redis](http://redis.io/) key-value store support fo
44

55
It includes a `Cache` and `Session` storage handler in redis.
66

7+
8+
[![Build Status](https://travis-ci.org/dcb9/yii2-phpredis.svg)](https://travis-ci.org/dcb9/yii2-phpredis)
9+
[![Code Climate](https://codeclimate.com/github/dcb9/yii2-phpredis/badges/gpa.svg)](https://codeclimate.com/github/dcb9/yii2-phpredis)
10+
[![Issue Count](https://codeclimate.com/github/dcb9/yii2-phpredis/badges/issue_count.svg)](https://codeclimate.com/github/dcb9/yii2-phpredis)
11+
[![Latest Stable Version](https://poser.pugx.org/dcb9/yii2-phpredis/version)](https://packagist.org/packages/dcb9/yii2-phpredis)
12+
[![Total Downloads](https://poser.pugx.org/dcb9/yii2-phpredis/downloads)](https://packagist.org/packages/dcb9/yii2-phpredis)
13+
[![License](https://poser.pugx.org/dcb9/yii2-phpredis/license)](https://packagist.org/packages/dcb9/yii2-phpredis)
14+
715
**<font color="red">Notice: THIS REPO DID NOT SUPPORT ACTIVE RECORD.</font>**
816

917
Requirements
@@ -52,3 +60,35 @@ return [
5260
]
5361
];
5462
```
63+
64+
Run unit test
65+
-------------
66+
67+
You can specific your redis config
68+
69+
```
70+
$ cp tests/config.php tests/config-local.php
71+
$ vim tests/config-local.php
72+
```
73+
74+
and Run
75+
76+
```
77+
$ ./vendor/bin/phpunit
78+
PHPUnit 5.6.1 by Sebastian Bergmann and contributors.
79+
80+
............ 12 / 12 (100%)
81+
82+
Time: 600 ms, Memory: 10.00MB
83+
84+
OK (12 tests, 50 assertions)
85+
```
86+
87+
Performance test
88+
------------------
89+
90+
```
91+
$ php tests/performance.php
92+
```
93+
94+
![phpredis-vs-yii-redis](./phpredis-vs-yii-redis.png)

composer.json

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,16 @@
1111
],
1212
"require": {
1313
"yiisoft/yii2": "~2.0.4",
14-
"ext-redis": ">=2.2.7"
14+
"ext-redis": ">=2.2.5",
15+
"php": ">=5.4.0"
1516
},
1617
"autoload": {
1718
"psr-4": {
1819
"dcb9\\redis\\": ""
1920
}
21+
},
22+
"require-dev": {
23+
"phpunit/phpunit": "*",
24+
"yiisoft/yii2-redis": "^2.0"
2025
}
2126
}

phpredis-vs-yii-redis.png

38.3 KB
Loading

tests/performance.php

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
<?php
2+
3+
include __DIR__ . "/bootstrap.php";
4+
5+
if (file_exists(__DIR__ . '/config-local.php')) {
6+
$param = include(__DIR__ . '/config-local.php');
7+
} else {
8+
$param = include(__DIR__ . '/config.php');
9+
}
10+
11+
$phpRedisConfig = $param['class'] = 'dcb9\redis\Connection';
12+
$yiiRedisConfig = $param['class'] = 'yii\redis\Connection';
13+
14+
$app = new \yii\console\Application([
15+
'id' => 'test-performance-app',
16+
'basePath' => __DIR__,
17+
'vendorPath' => dirname(__DIR__) . '/vendor',
18+
'components' => [
19+
'phpRedis' => $phpRedisConfig,
20+
'yiiRedis' => $yiiRedisConfig,
21+
],
22+
]);
23+
24+
$count = 10000;
25+
echo "phpredis run SET $count times in";
26+
$start = microtime(true);
27+
/* @var $phpRedis \dcb9\redis\Connection */
28+
$phpRedis = Yii::$app->phpRedis;
29+
$phpRedis->open();
30+
$phpRedis->flushdb();
31+
for ($i = 0; $i < $count; $i++) {
32+
$phpRedis->set('php_redis_prefix' . $i, $i);
33+
}
34+
echo " " . ((microtime(true) - $start) * 1000) . " micro seconds.\n";
35+
36+
echo "yii redis run SET $count times in";
37+
$start = microtime(true);
38+
/* @var $yiiRedis \yii\redis\Connection */
39+
$yiiRedis = Yii::$app->yiiRedis;
40+
$yiiRedis->flushdb();
41+
for ($i = 0; $i < $count; $i++) {
42+
$yiiRedis->set('yii_redis_prefix' . $i, $i);
43+
}
44+
echo " " . ((microtime(true) - $start) * 1000) . " micro seconds.\n";
45+
46+
echo "phpredis run GET $count times in";
47+
$start = microtime(true);
48+
for ($i = 0; $i < $count; $i++) {
49+
$phpRedis->get('php_redis_prefix' . $i);
50+
}
51+
echo " " . ((microtime(true) - $start) * 1000) . " micro seconds.\n";
52+
53+
echo "yii redis run GET $count times in";
54+
$start = microtime(true);
55+
for ($i = 0; $i < $count; $i++) {
56+
$yiiRedis->get('yii_redis_prefix' . $i);
57+
}
58+
echo " " . ((microtime(true) - $start) * 1000) . " micro seconds.\n";

0 commit comments

Comments
 (0)