zoukankan      html  css  js  c++  java
  • redis入门(数据类型)

    • 数据类型
    1) 字符串类型 string
    2) 哈希类型 hash:      map
    3) 列表类型 list:      linkedlist格式。支持重复元素
    4) 集合类型 set:      不允许重复元素
    5) 有序集合类型 sortedset: 不允许重复元素,且元素有顺序

    1)string
    127.0.0.1:6379> set uname fff
    OK
    127.0.0.1:6379> get uname
    "fff"
    127.0.0.1:6379> del uname
    (integer) 1
    127.0.0.1:6379> keys *
    (empty list or set)
    2)hash
    127.0.0.1:6379> hset mhash username zhangsan
    (integer) 1
    127.0.0.1:6379> hset mhash password 123
    (integer) 1
    127.0.0.1:6379> hget mhash username
    "zhangsan"
    127.0.0.1:6379> hgetall mhash
    1) "username"
    2) "zhangsan"
    3) "password"
    4) "123"
    127.0.0.1:6379> hdel mhash password
    (integer) 1
    127.0.0.1:6379> hgetall mhash
    1) "username"
    2) "zhangsan"
    3)list
    127.0.0.1:6379> lpush room a
    (integer) 1
    127.0.0.1:6379> lpush room b
    (integer) 2
    127.0.0.1:6379> rpush room c
    (integer) 3
    127.0.0.1:6379> lrange room 0 -1  0 -1可以显示所有,若是 1 3 则显示从左往右第二个至第四个
    1) "b"
    2) "a"
    3) "c"
    127.0.0.1:6379> lpush room d
    (integer) 4
    127.0.0.1:6379> lrange room 0 -1
    1) "d"
    2) "b"
    3) "a"
    4) "c"
    127.0.0.1:6379> rpop room
    "c"
    127.0.0.1:6379> lrange room 0 -1
    1) "d"
    2) "b"
    3) "a"
    4)set
    127.0.0.1:6379> sadd fruits apple
    (integer) 1
    127.0.0.1:6379> sadd fruits apple
    (integer) 0
    127.0.0.1:6379> sadd fruits pear
    (integer) 1
    127.0.0.1:6379> smembers fruits
    1) "pear"
    2) "apple"
    127.0.0.1:6379> srem fruits pear
    (integer) 1
    127.0.0.1:6379> smembers fruits
    1) "apple"
    5)sortedset
    127.0.0.1:6379> zadd test 46 hong
    (integer) 1
    127.0.0.1:6379> zadd test 44 li
    (integer) 1
    127.0.0.1:6379> zadd test 60 zhang
    (integer) 1
    127.0.0.1:6379> zrange test 0 -1
    1) "li"
    2) "hong"
    3) "zhang"
    127.0.0.1:6379> zrem test hong
    (integer) 1
    127.0.0.1:6379> zrange test 0 -1
    1) "li"
    2) "zhang"

    通用命令

    127.0.0.1:6379> keys *
    1) "test"
    2) "fruits"
    3) "room"
    4) "mhash"
    127.0.0.1:6379> type fruits    获取类型
    set
    127.0.0.1:6379> type test
    zset
    127.0.0.1:6379> del mhash
    (integer) 1
    127.0.0.1:6379> keys *
    1) "test"
    2) "fruits"
    3) "room"
  • 相关阅读:
    laravel常用函数大全Helper
    laravel查询语句指定索引(mysql强制索引)
    laravel-admin后台系统开发
    ES搜索引擎详解
    怎么查看当前的git分支是基于哪个分支创建的
    laravel中使用offsetSet
    laragon安装新的php版本
    Laravel collect妙用
    composer install file could not be downloaded (HTTP/1.1 405 Not Allowed)
    garphql
  • 原文地址:https://www.cnblogs.com/Nora-F/p/11085367.html
Copyright © 2011-2022 走看看