In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-29 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/02 Report--
Today, I will talk to you about the redis command and RedisTemplate operation corresponding table. Many people may not know much about it. In order to let you know more, Xiaobian summarizes the following contents for you. I hope you can gain something according to this article.
redis command and RedisTemplate operation mapping table
redisTemplate.opsForValue();//action string
redisTemplate.opsForHash();//operation hash
redisTemplate.opsForedisTemplateet();//operation set
redisTemplate.opsForList();//action list
redisTemplate.opsForZSet();//operation ordered set
Key related Redis command RedisTemplate redisTemplate description KEYS *, KEYS *key*, KEYS *key, KEYS key*redisTemplate.keys(key); get all keys, fuzzy query key (wildcard * supported) EXPIRE key 10 EXPIRE key 1293840000redisTemplate.expire (key, time, TimeUnit.SECONDS);redisTemplate.expireAt (key, date); Specify key cache expiration Specify key cache expiration TTL keyredisTemplate.getExpire (key, TimeUnit.SECONDS); Get expiration time by key EXISTS keyEXISTS key1 key2 key3redisTemplate.hasKey(key);redisTemplate.countExistingKeys (Arrays.asList(key)); Determine if key exists Check the number of keys exist DEL keyDEL key1 key2 key3redisTemplate.delete(key);redisTemplate.delete(Arrays.asList(keys)); Delete specified key Cache Delete key in batches
String Related
redisTemplate.opsForValue();//action string
Redis command RedisTemplate redisTemplate description SET key valueSET key value timeredisTemplate.opsForValue().set (key,value);redisTemplate.opsForValue().set (key,value,time); Set normal cache Set normal cache expiration time GET keyredisTemplate.opsForValue().get(key); Get normal cache INCE keyredisTemplate.opsForValue(). increase (key, delta); increment DECR keyredisTemplate.opsForValue(). increase (key, -delta); decrement SETNX key valueredisTemplate.opsForValue().setIfAbsent (key,value); Set the value of key to value if and only if SETEX key valueredisTemplate.opsForValue().setIfPresent(key,value); Determine whether the current key value is v, if yes, do not operate, if false, replace. Without this key, nothing will be done. GETSET key valueredisTemplate.opsForValue().getAndSet(key, value);key exists Set new value and return old value
Hash-related
redisTemplate.opsForHash();//operation string
Redis command RedisTemplate redisTemplate description HMSET key key1 value1 key2 value2redisTemplate.opsForHash().putAll(key, map); Set cache HSET key item valueredisTemplate.opsForHash().put(key, item, value); Put data into a hash table, if it does not exist will create HGET key itemredisTemplate.. opsForHash().get (key, item); Get cache, field value HMGET keyredisTemplate.opsForHash().entries(key); Get all key values corresponding to hashKey Delete key item1 item2 item3redisTemplate.opsForHash().delete (key, item); Set the value of key to value if and only if key does not exist HEXISTS key itemredisTemplate.opsForHash().hasKey (key, item); Determine whether there is a value for the item in the hash table HINCRBY key item byredisTemplate.opsForHash(). increase (key, item, by);hash incrementIf it doesn't exist, it creates one and returns it to HDEL key item byredisTemplate.opsForHash().increment(key, item, -by);hash decrement
Set Related
redisTemplate. opsForedisTemplate ();//action string
Redis command RedisTemplate redisTemplate description SMEMBER redisTemplate keyredisTemplate. opsForedisTemplate (). memberdisTemplate (key) Gets all values in the Set by key SISMBER key valueredisTemplate. opsForedisTemplate ().isMember (key, value); Query from a set according to value, whether there is SADD key value1 value2redisTemplate.opsForedisTemplateet().add (key, values); puts data in set cache SCARD keyredisTemplate. opsForedisTemplate ().size(key); gets length of set cache SREM key value1 value2redisTemplate. opsForedisTemplate ().remove(key, values); removes value
List related
redisTemplate.opsForList();//action string
Redis command RedisTemplate redisTemplate description `RPUSH key value``redisTemplate.opsForList().rightPush (key, value); Put list in cache, add LPUSH key valueredisTemplate.opsForList().leftPush from right (key, value); Put list in cache, add LRANGE key 0 -1redisTemplate.opsForList().range from left (key, start, end); Get contents of list cache LLEN keyredisTemplate.opsForList().size(key); Get length of list cache LINDEX key indexredisTemplate.opsForList().index (key, index); Get the value in the list by index LSET key index valueredisTemplate.opsForList().set(key, index, value); Modify a piece of data in the list according to the index LREM key count valueredisTemplate.opsForList().remove(key, count, value); Remove N values as value After reading the above, do you have any further understanding of how the redis command and RedisTemplate operation corresponding table are? If you still want to know more knowledge or related content, please pay attention to the industry information channel, thank you for your support.
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.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.