rain
2024-08-12 dbecdea3ad1768d1c7f8e88a2d3b64193c62352a
src/main/java/com/dji/sample/component/redis/RedisOpsUtils.java
@@ -1,6 +1,7 @@
package com.dji.sample.component.redis;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisCallback;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Component;
import org.springframework.util.CollectionUtils;
@@ -107,6 +108,13 @@
     * @return
     */
    public static Object get(String key) {
        // Execute the select command to choose the Redis database
        redisTemplate.execute((RedisCallback<Object>) connection -> {
            connection.select(1); // Choose database index 1
            return null;
        });
        // Now perform the get operation
        return redisTemplate.opsForValue().get(key);
    }