Introduction to NoSQL (iv)

Source: Internet
Author: User

Introduction to NoSQL (iv)

Redis Common operations

Redis Common Operations-string

set key3 zsset key3 lisi  //第二次赋值会覆盖setnx key3 wangwu  //返回0,则key3存在setnx key4 zhaoliu  //返回1,则key4不存在创建key4setex key4 100 tianqi //给key4设置过期时间为100s,值为tianqi,若key4存在则覆盖

Redis Common Operations-list

lpush listb a //从左侧加入一个元素lpop listb a //从左侧取出一个元素rpush listb b //从右侧加入一个元素rpop listb //从右侧取出第一个元素linsert lista before a 1 //在(值)a的前面插入(值)1lset lista 3 3 //把下标为3对应的数值改为3lindex lista 3 //查看下标为3对应的数值llen lista //查看链表lista有多少个元素

Redis Common Operations-set

sadd seta aaa //向集合seta中放入元素aaasmembers seta //查看seta集合的所有元素srem seta aaa //删除aaaspop seta //随机取出一个元素,删除sdiff seta setb //求差集,以seta为标准sdiffstore setc seta setb //求seta与setb的差集,将差集结果存入到setc中sinter seta setb //求交集sinterstore setd seta setb //将交集存储到setdsunion seta setb //求并集sunionstore sete seta setb //求并集并存储到setesismember seta aaa  //判断一个元素是否属于一个集合srandmember seta //随机取出一个元素,但不删除

Introduction to NoSQL (iv)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.