YOLO v5 Series - Redis Configuration

在这里插入图片描述
Secret

D:\msys64\home\unix2linux\lua2\redis>echo %DATE%T%TIME%
2024-12-31T 8:55:47.94
D:\msys64\home\unix2linux\lua2\redis>printf "%DATE%%TIME%" | openssl dgst -md5
MD5(stdin)= b40c65cc4796709fea4fb6e370ab355b

D:\msys64\home\unix2linux\lua2\redis>uuidgen
e9ce2966-8cf6-4e80-862e-1914261ee784
D:\msys64\home\unix2linux\lua2\redis>uuidgen | openssl dgst -md5
MD5(stdin)= 64763802aba6d3b6e67505659a36b4fd

D:\msys64\home\unix2linux\lua2\redis>linux_date +"%s%N"
1735606709895182500
D:\msys64\home\unix2linux\lua2\redis>linux_date +"%s%N" | openssl dgst -md5
MD5(stdin)= e88ac702f6da42dd731179501d5e7aec

在这里插入图片描述
Auth

D:\msys64\home\unix2linux\lua2\redis>redis-cli -a e88ac702f6da42dd731179501d5e7aec
Warning: Using a password with '-a' or '-u' option on the command line interface may not be safe.
127.0.0.1:6379> config get requirepass
1) "requirepass"
2) "e88ac702f6da42dd731179501d5e7aec"
127.0.0.1:6379>

Configure

###############################################################################
requirepass 'e88ac702f6da42dd731179501d5e7aec' 
###############################################################################
dbfilename "dump.rdb"

save 900 1
save 300 10
save 60 10000
###############################################################################

Keys

D:\msys64\home\unix2linux\lua2\redis>red
Warning: Using a password with '-a' or '-u' option on the command line interface may not be safe.
127.0.0.1:6379> config get dir
1) "dir"
2) "D:\\msys64\\home\\unix2linux\\lua2\\redis"
127.0.0.1:6379> keys *
(empty array)
127.0.0.1:6379> save
OK
127.0.0.1:6379> flushall
OK
127.0.0.1:6379> ping
PONG

Flush

127.0.0.1:6379> flushdb
OK
127.0.0.1:6379> flushall
OK
127.0.0.1:6379>

Data Dictionary : Run Mode

[
    {
        "ID": 0, 
        "Key": "ON", 
        "Value": "running", 
        "Data": "", 
        "Description": ""
    }, 
    {
        "ID": 1, 
        "Key": "OFF", 
        "Value": "freezing", 
        "Data": "", 
        "Description": ""
    }
]

Data Dictionary : Predict Mode

[
    {
        "ID": 0, 
        "Key": "YOLO V5", 
        "Value": "yolov5s.pt", 
        "Data": "", 
        "Description": ""
    }, 
    {
        "ID": 1, 
        "Key": "Fireworks V1", 
        "Value": "fireworksv1.pt", 
        "Data": "", 
        "Description": ""
    }
]
127.0.0.1:6379> set data-dictionary:run-mode "[{'ID':0,'Key':'ON','Value':'running','Data':'','Description':''},{'ID':1,'Key':'OFF','Value':'freezing','Data':'','Description':''}]"
OK
127.0.0.1:6379> set data-dictionary:predict-mode "[{'ID':0,'Key':'YOLO V5','Value':'yolov5s.pt','Data':'','Description':''},{'ID':1,'Key':'Fireworks V1','Value':'fireworksv1.pt','Data':'','Description':''}]"
OK
127.0.0.1:6379> save
OK
127.0.0.1:6379> keys *
1) "data-dictionary:predict-mode"
2) "data-dictionary:run-mode"
127.0.0.1:6379> get data-dictionary:run-mode
"[{'ID':0,'Key':'ON','Value':'running','Data':'','Description':''},{'ID':1,'Key':'OFF','Value':'freezing','Data':'','Description':''}]"
127.0.0.1:6379> get data-dictionary:predict-mode
"[{'ID':0,'Key':'YOLO V5','Value':'yolov5s.pt','Data':'','Description':''},{'ID':1,'Key':'Fireworks V1','Value':'fireworksv1.pt','Data':'','Description':''}]"

Data Dictionary List

D:\msys64\home\unix2linux\lua2\redis>curl "http://localhost:9999/api/redis/dictionary/list?master=run-mode&slave=0"
{
  "code": 0,
  "msg": "success",
  "data": {
    "master": "run-mode",
    "slave": "0",
    "token": [
      {
        "ID": 0,
        "Key": "ON",
        "Value": "running",
        "Data": "",
        "Description": ""
      }
    ]
  }
}
D:\msys64\home\unix2linux\lua2\redis>curl "http://localhost:9999/api/redis/dictionary/list?master=predict-mode"
{
  "code": 0,
  "msg": "success",
  "data": {
    "master": "predict-mode",
    "slave": "",
    "token": [
      [
        {
          "Data": "",
          "Description": "",
          "ID": 0,
          "Key": "YOLO V5",
          "Value": "yolov5s.pt"
        },
        {
          "Data": "",
          "Description": "",
          "ID": 1,
          "Key": "Fireworks V1",
          "Value": "fireworksv1.pt"
        }
      ]
    ]
  }
}

Data Dictionary Save

D:\msys64\home\unix2linux\lua2\redis>curl -H "Accept: application/json" -H "Content-type: application/json" -X POST -d "{\"ID\":0,\"Name\":\"redis\"}" "http://localhost:9999/api/redis/dictionary/save?master=view-mode"
{
  "code": 0,
  "msg": "success",
  "data": {
    "master": "view-mode",
    "slave": "",
    "body": {
      "ID": 0,
      "Name": "redis"
    }
  }
}

/api/redis/dictionary/all

location /api/redis/dictionary/all {
    content_by_lua_block {
		ngx.header.content_type = 'text/html; charset=utf-8'
        local args = ngx.req.get_uri_args()

        local result, ok, err, respond;
        local cjson = require "cjson.safe"
        local redis = require "resty.redis";
        local red = redis:new();

        ok, err = red:connect("127.0.0.1", 6379);
        ok, err = red:auth(ngx.var.client_redis_secret)
        if not ok then
            result = string.format('{"code":1,"msg":"error","data":{"token":"%s","body":[]}}', args['token'])
   			return ngx.say(result)
        end

        local dictionary = 'data-dictionary'
        local token = string.format('%s*', dictionary)
        local keys, err = red:keys(token)
        local line = '['
        for i, key in ipairs(keys) do
            line = line .. '"' .. string.sub(key, (string.len(dictionary) + 2)) .. '",'
        end
        line = line .. ']'
        line = string.gsub(line, ',]', ']')
        red:close()

        result = string.format('{"code":0,"msg":"success","data":{"token":"%s","body":%s}}', dictionary, line)
		return ngx.say(result)
    }
}

在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
Stop Propagation

var reloadMaster = function() {
    $(document).on('mousedown', '.token-remove-cell', function(e) {
        e.preventDefault();
        e.stopPropagation();

        var token = $(this).attr('data-token');
        Swal.fire({
            title: 'Are you sure?',
            text: 'You will delete item (' + token + ').',
            icon: 'warning',
            showCancelButton: true,
            confirmButtonText: 'Yes'
        }).then(function (result) {
            if (result.value) {
                triggerRemoveItem(token);
                triggerReload();
            }
        });
    });
};

在这里插入图片描述
在这里插入图片描述

在这里插入图片描述
在这里插入图片描述

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值