| | |
| | | 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; |
| | |
| | | * @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); |
| | | } |
| | | |