java 手写 jvm高性能缓存,键值对存储,队列存储,存储超时设置

缓存接口

 1 package com.ws.commons.cache;
 2 
 3 import java.util.function.Function;
 4 
 5 public interface ICache {
 6 
 7     void expire(String key, int timeOutSecond);
 8 
 9     void leftPush(String key, Object value);
10 
11     void rightPush(String key, Object value);
12 
13     void rightPush(String key, Object value, int timeOutSecond);
14 
15     <T> T rightPop(String key);
16 
17     <T> T leftPop(String key);
18 
19     public <T> T computeIfAbsent(String key, int outSecond, Function<String, Object> mappingFunction);
20 
21     void put(String key, Object value);
22 
23     void put(String key, Object value, int timeOutSecond);
24 
25     boolean putIfAbsent(String key, Object value);
26 
27     boolean putIfAbsent(String key, Object value, int timeOutSecond);
28 
29     <T> T get(String key);
30 
31     boolean hasKey(String key);
32 
33     void remove(String key);
34 
35     <T> T removeAndGet(String key);
36 }
View Code

相关文章: