CodingYang

vuePress-theme-reco Rackar    2018 - 2024
CodingYang CodingYang

Choose mode

  • dark
  • auto
  • light
首页
类别
  • 技术
  • 个人
  • 思考
  • 儿童
标签
时间线
联系
  • 关于
  • RSS订阅 (opens new window)
  • GitHub (opens new window)
  • 简书 (opens new window)
  • CSDN (opens new window)
  • WeChat (opens new window)
GitHub (opens new window)
author-avatar

Rackar

67

文章

44

标签

首页
类别
  • 技术
  • 个人
  • 思考
  • 儿童
标签
时间线
联系
  • 关于
  • RSS订阅 (opens new window)
  • GitHub (opens new window)
  • 简书 (opens new window)
  • CSDN (opens new window)
  • WeChat (opens new window)
GitHub (opens new window)
  • Redis Docker

    • wsl 安装
      • 基本教程

      Redis Docker

      vuePress-theme-reco Rackar    2018 - 2024

      Redis Docker


      Rackar 2022-12-03 redis

      # wsl 安装

      e 盘新建 redisdata/data 目录和 redisdata/redis.conf,写入

      #bind 127.0.0.1 #允许远程连接
      protected-mode no
      appendonly yes
      requirepass 123456
      
      1
      2
      3
      4

      执行

      docker pull redis
      docker run --name my_redis -p 6379:6379 -v /mnt/e/redisdata/data:/data -v /mnt/e/redisdata/redis.conf:/etc/redis/redis.conf -d redis redis-server /etc/redis/redis.conf
      docker exec -it my_redis redis-cli
      set name test
      auth 123456
      get name
      
      1
      2
      3
      4
      5
      6

      如果失败的话查看日志

      docker logs my_redis
      
      1

      # 基本教程

      set mykey newval nx
      set mykey newval xx
      # nx 只能创建新键
      # xx 只能修改已有的键
      
      
      > set counter 100
      OK
      > incr counter
      (integer) 101
      > incr counter
      (integer) 102
      > incrby counter 50
      (integer) 152
      # 数字自增incr+1 以及自减DECR和DECRBY。
      # 以及GETSET ,设定新值同时返回旧值
      
      > mset a 10 b 20 c 30
      OK
      > mget a b c
      1) "10"
      2) "20"
      3) "30"
      # 批量设置和查询
      
      1
      2
      3
      4
      5
      6
      7
      8
      9
      10
      11
      12
      13
      14
      15
      16
      17
      18
      19
      20
      21
      22
      23
      24
      参与编辑此文章 (opens new window)
      更新于: 8/30/2023, 3:34:39 PM