|  | @@ -3,6 +3,7 @@ package thyyxxk.webserver.service;
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  import com.google.errorprone.annotations.concurrent.UnlockMethod;
 | 
	
		
			
				|  |  |  import lombok.extern.slf4j.Slf4j;
 | 
	
		
			
				|  |  | +import org.apache.poi.ss.formula.functions.T;
 | 
	
		
			
				|  |  |  import org.springframework.data.redis.core.RedisTemplate;
 | 
	
		
			
				|  |  |  import org.springframework.stereotype.Component;
 | 
	
		
			
				|  |  |  
 | 
	
	
		
			
				|  | @@ -12,6 +13,11 @@ import java.util.function.Function;
 | 
	
		
			
				|  |  |  @Component
 | 
	
		
			
				|  |  |  public class RedisServer {
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | +    @FunctionalInterface
 | 
	
		
			
				|  |  | +    public interface CyConsumer<T> {
 | 
	
		
			
				|  |  | +        T accept();
 | 
	
		
			
				|  |  | +    }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  |      private final RedisTemplate<String, Object> redisTemplate;
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |      public RedisServer(RedisTemplate<String, Object> redisTemplate) {
 | 
	
	
		
			
				|  | @@ -47,6 +53,20 @@ public class RedisServer {
 | 
	
		
			
				|  |  |          return (T) o;
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | +    @SuppressWarnings("unchecked")
 | 
	
		
			
				|  |  | +    public <T> T getData(String key, CyConsumer<T> function) {
 | 
	
		
			
				|  |  | +        Object o = redisTemplate.opsForValue().get(key);
 | 
	
		
			
				|  |  | +        if (o == null) {
 | 
	
		
			
				|  |  | +            if (function == null) {
 | 
	
		
			
				|  |  | +                throw new RuntimeException("function should not be null");
 | 
	
		
			
				|  |  | +            }
 | 
	
		
			
				|  |  | +            T data = function.accept();
 | 
	
		
			
				|  |  | +            setData(key, data);
 | 
	
		
			
				|  |  | +            return data;
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +        return (T) o;
 | 
	
		
			
				|  |  | +    }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |      public Boolean delData(String key) {
 | 
	
		
			
				|  |  |          return redisTemplate.delete(key);
 |