WANG 6 жил өмнө
parent
commit
0047274bfc

+ 14 - 4
src/main/java/cn/com/qmth/examcloud/support/cache/CacheHelper.java

@@ -6,9 +6,17 @@ import org.assertj.core.util.Arrays;
 import cn.com.qmth.examcloud.support.cache.bean.AppCacheBean;
 import cn.com.qmth.examcloud.support.cache.bean.SysPropertyCacheBean;
 import cn.com.qmth.examcloud.web.cache.ObjectRedisCacheTrigger;
+import cn.com.qmth.examcloud.web.cache.RandomCacheBean;
 import cn.com.qmth.examcloud.web.redis.RedisClient;
 import cn.com.qmth.examcloud.web.support.SpringContextHolder;
 
+/**
+ * 所有缓存对象从此类获取
+ *
+ * @author WANGWEI
+ * @date 2019年5月9日
+ * @Copyright (c) 2018-? http://qmth.com.cn All Rights Reserved.
+ */
 public class CacheHelper {
 
 	private static RedisClient redisClient;
@@ -40,17 +48,19 @@ public class CacheHelper {
 	 * @param className
 	 * @return
 	 */
-	private static <T> T get(String keyPrefix, Object[] propKeys, Class<T> c, String appName,
-			String className) {
+	private static <T> T get(String keyPrefix, Object[] propKeys,
+			Class<? extends RandomCacheBean> c, String appName, String className) {
 
 		String key = keyPrefix + StringUtils.join(Arrays.asList(propKeys), '_');
 
-		T t = getRedisClient().get(key, c);
+		RandomCacheBean t = getRedisClient().get(key, c);
 		if (null == t) {
 			getObjectRedisCacheTrigger().fire(appName, className, propKeys);
 			t = getRedisClient().get(key, c);
 		}
-		return t;
+		@SuppressWarnings("unchecked")
+		T ret = (T) t;
+		return ret;
 	}
 
 	/**