Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What are the problems with redis

2025-04-10 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/01 Report--

This article mainly shows you "what are the redis problems", the content is easy to understand, clear, hope to help you solve your doubts, the following let the editor lead you to study and learn "what are the redis problems" this article?

Redis's threading model: redis is a single-threaded model, implemented using epoll multiplexer, file event handling, and then file event distribution

Redis data types: String, List, Hash, Set, Zset

RedisTemplate.opsForValue (); / / Operation string

RedisTemplate.opsForHash (); / / operate hash

RedisTemplate.opsForList (); / / operate list

RedisTemplate.opsForSet (); / / operate set

RedisTemplate.opsForZSet (); / / operate orderly set

String

Set ("num", "redisTemplate.opsForValue")

RedisTemplate.opsForValue () .get (num)

The output is 123

RedisTemplate.opsForValue () .set ("num", "123,10, TimeUnit.SECONDS)"

RedisTemplate.opsForValue (). Get ("num") is set to expire in 10 seconds, query results within 10 seconds, and return to null after 10 seconds

Template.opsForValue (). GetAndSet ("getSetTest", "test2") / / sets the string value of the key and returns its old value

Template.opsForValue () .size ("key") / / returns the value worth length corresponding to key

Hash

Delete the given hash hashKeys

Template.opsForHash () .delete ("redisHash", "name") / / result:

Template.opsForHash () .entries ("redisHash") / / result: {class=6, age=28.1}

Determine whether the hash hashKey exists

Template.opsForHash () .hasKey ("redisHash", "666") / / result: true

Template.opsForHash () .hasKey ("redisHash", "777") / / result: false

Gets the value of a given hashKey from the hash in the key

Template.opsForHash () .get ("redisHash", "age"); / / result: 26

Get the key,redisHash of the hash table corresponding to key and the hash table corresponding to {class=1, name=666, age=27}

Template.opsForHash () .keys ("redisHash") / / result: [name, class, age]

Set the value of the hash hashKey

Template.opsForHash () .put ("redisHash", "name", "666")

Template.opsForHash () .put ("redisHash", "age" 26)

Template.opsForHash () .put ("redisHash", "class", "6")

Template.opsForHash () .entries ("redisHash") / / result: {age=26, class=6, name=666}

Get the entire hash stored value according to the key

Template.opsForHash () .values ("redisHash"); / / result: [tom, 26,6]

List

Inserts all specified values into the header of the list stored in the key

Template.opsForList (. LeftPush ("list", "java")

Insert an array into the list in batch

String [] strs = new String [] {"1", "2", "3"}

Template.opsForList () .leftPushAll (list, strs)

Template.opsForList () .range ("list", 0mam muri 1) / / result: [3,2,1]

Void set (K key, long index, V value)

Set the value value at the location of index in the list

Template.opsForList () .range ("listRight", 0mam muri 1) / / result: [java, python, oc, C++]

Template.opsForList () .set (listRight, 1, setValue)

Template.opsForList () .range ("listRight", 0mam muri 1) / / result: [java, setValue, oc, C++]

Removes the first count event of an element equal to a value from the list stored in the key.

The count parameter affects the operation in the following ways:

Count > 0: deletes an element equal to the value moved from beginning to end.

Count

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report