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

How to call redis string type interface in Java

2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

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

How to call the redis string type interface in Java? for this problem, this article introduces the corresponding analysis and solution in detail, hoping to help more partners who want to solve this problem to find a more simple and feasible method.

String data Type (String) API description

String type is the most basic data storage type in Redis, and it is binary safe in Redis, which means that this type can accept data in any format, such as JPEG image data or Json object description information. The maximum length of data that a string type Value can hold in Redis is 512m.

# set the Key to hold the specified string Value, and overwrite its original value if the Key already exists.

Void set (final String key, final String value)

# get the Value of the specified Key, and return null if the Key does not exist.

Byte [] get (final String key)

# determine whether the key exists. If it exists, it returns 1, otherwise 0.

Boolean exists (final String key)

/ / Delete the specified Key

Long delete (final String... Keys)

/ / rename the specified Key. If the commands of the two Keys in the parameters are the same, or the source Key does not exist, the command will return the relevant error message. If newKey already exists, it is overwritten directly.

Void rename (final String oldkey, final String newkey)

/ / if the new value does not exist, change the original value in the parameter to the new value. Other conditions are consistent with RENAME.

Boolean renamenx (final String oldkey, final String newkey)

/ / sets the expiration time (in seconds) of a key. After that time, the Key is automatically deleted. If the Key is modified before the timeout, the timeout associated with the key is removed.

Boolean expire (final String key, final int seconds)

# EXPIREAT is similar to EXPIRE in that it is used to set the time to live for key. The difference is that the time parameter accepted by the EXPIREAT command is the UNIX timestamp (unix timestamp).

Boolean expireAt (final String key, final long unixTime)

# check the remaining survival time (in seconds) of the specified Key through the ttl command. 0 means it has expired and-1 means it will never expire. Long ttl (final String key)

# move the mysetkey key from the current database to the database whose ID is dbIndex

Boolean move (final String key, final int dbIndex)

# atomicity sets the Key to the specified Value, returns the original value of the Key, and returns null if the Key does not exist before.

Byte [] getSet (final String key, final String value)

# returns a list of Values for the specified Keys.

List mget (final String... Keys)

# if the specified Key does not exist, set the Key to hold the specified string Value, which is equivalent to the SET command. Conversely, if the Key already exists, the command does nothing and returns.

Boolean setnx (final String key, final String value)

Boolean setex (final String key, final int seconds, final String value)

# this command atomically completes the setting operation of all key/value in the parameters. If any Key already exists in this batch of Keys, then all the operations will be rolled back, that is, all changes will not take effect.

Boolean msetnx (final String... Keysvalues)

# will specify an increment of 1 for the Value atomicity of Key. If the Key does not exist, its initial value is 0, and its value is 1 after incr, which returns the incremented value.

Void incrBy (final String key, final long integer) {

Void incr (final String key)

# will specify that the Value atomicity of the Key is decremented by 1. If the Key does not exist, its initial value is-1, and its value is 1 after incr, returning the decremented value.

Long decrBy (final String key, final long integer)

Long decr (final String key)

# if the Key already exists, the APPEND command appends the data of the parameter Value to the end of the existing Value. If the Key does not exist, the APPEND command will create a new Key/Value. Returns the length of the appended Value.

Long append (final String key, final String value)

This is the answer to the question about how to call the redis string type interface in Java. I hope the above content can be of some help to you. If you still have a lot of doubts to be solved, you can follow the industry information channel for more related knowledge.

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

Servers

Wechat

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

12
Report