mx 3 年 前
コミット
b82bfe459c
5 ファイル変更82 行追加5 行削除
  1. 10 1
      README.md
  2. 6 0
      app/controller/Index.php
  3. 2 1
      composer.json
  4. 55 1
      composer.lock
  5. 9 2
      config/redis.php

+ 10 - 1
README.md

@@ -29,4 +29,13 @@
 NOTICE
 1. 重復執行 3 會重復插入數據
 2. 3 所有插入爲同一個事務
-3. 3 事務執行失敗會引起ID自增 (pgsql)
+3. 3 事務執行失敗會引起ID自增 (pgsql)
+
+### Redis
+
+see [official doc](https://www.workerman.net/doc/webman/db/redis.html)
+
+NOTICE
+
+composer 安裝 並配置後,需要重啓: `php start.php start`
+

+ 6 - 0
app/controller/Index.php

@@ -3,6 +3,7 @@
 namespace app\controller;
 
 use support\Request;
+use support\Redis;
 
 class Index
 {
@@ -18,6 +19,11 @@ class Index
 
     public function json(Request $request)
     {
+        Redis::set('good', 'well');
+
+        // another way
+        $r = Redis::connection('cache');
+        $r->set('good', 'cache');
         return json(['code' => 0, 'msg' => 'ok']);
     }
 

+ 2 - 1
composer.json

@@ -30,7 +30,8 @@
     "illuminate/database": "^8.83",
     "illuminate/pagination": "^8.83",
     "illuminate/events": "^8.83",
-    "robmorgan/phinx": "^0.12.10"
+    "robmorgan/phinx": "^0.12.10",
+    "illuminate/redis": "^8.83"
   },
   "suggest": {
     "ext-event": "For better performance. "

+ 55 - 1
composer.lock

@@ -4,7 +4,7 @@
         "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
         "This file is @generated automatically"
     ],
-    "content-hash": "fd3b4be730663f4bcad5cbb7244fa57f",
+    "content-hash": "453c200f680a5bce1d0f24764354fe81",
     "packages": [
         {
             "name": "cakephp/core",
@@ -799,6 +799,60 @@
             },
             "time": "2021-03-26T18:39:16+00:00"
         },
+        {
+            "name": "illuminate/redis",
+            "version": "v8.83.5",
+            "source": {
+                "type": "git",
+                "url": "https://github.com/illuminate/redis.git",
+                "reference": "0fee121324054226823a59623fab3d98ad88fbd5"
+            },
+            "dist": {
+                "type": "zip",
+                "url": "https://api.github.com/repos/illuminate/redis/zipball/0fee121324054226823a59623fab3d98ad88fbd5",
+                "reference": "0fee121324054226823a59623fab3d98ad88fbd5",
+                "shasum": ""
+            },
+            "require": {
+                "illuminate/collections": "^8.0",
+                "illuminate/contracts": "^8.0",
+                "illuminate/macroable": "^8.0",
+                "illuminate/support": "^8.0",
+                "php": "^7.3|^8.0"
+            },
+            "suggest": {
+                "ext-redis": "Required to use the phpredis connector (^4.0|^5.0).",
+                "predis/predis": "Required to use the predis connector (^1.1.9)."
+            },
+            "type": "library",
+            "extra": {
+                "branch-alias": {
+                    "dev-master": "8.x-dev"
+                }
+            },
+            "autoload": {
+                "psr-4": {
+                    "Illuminate\\Redis\\": ""
+                }
+            },
+            "notification-url": "https://packagist.org/downloads/",
+            "license": [
+                "MIT"
+            ],
+            "authors": [
+                {
+                    "name": "Taylor Otwell",
+                    "email": "taylor@laravel.com"
+                }
+            ],
+            "description": "The Illuminate Redis package.",
+            "homepage": "https://laravel.com",
+            "support": {
+                "issues": "https://github.com/laravel/framework/issues",
+                "source": "https://github.com/laravel/framework"
+            },
+            "time": "2022-01-24T02:32:30+00:00"
+        },
         {
             "name": "illuminate/support",
             "version": "v8.83.5",

+ 9 - 2
config/redis.php

@@ -15,8 +15,15 @@
 return [
     'default' => [
         'host' => '127.0.0.1',
-        'password' => null,
+        'password' => '123456',
         'port' => 6379,
-        'database' => 0,
+        'database' => 2,
+    ],
+
+    'cache' => [
+        'host' => '127.0.0.1',
+        'password' => '123456',
+        'port' => 6379,
+        'database' => 1,
     ],
 ];