// Path: jbase-cache/src/main/java/com/jayqqaa12/jbase/cache/provider/SerializerCache.java
// public abstract class SerializerCache implements Cache {
// 
//   private final CacheSerializer cacheSerializer;
// 
//   public SerializerCache(CacheSerializer cacheSerializer) {
//     this.cacheSerializer = cacheSerializer;
// 
//   }
// 
//   @Override
//   public CacheObject get(String key) throws CacheException {
//     try {
//       byte[] bytes = getByte(key);
//       return (CacheObject) cacheSerializer.deserialize(bytes);
//     } catch (Exception e) {
//       throw new CacheException(key + " deserialize error ", e);
//     }
//   }
// 
// 
// 
//   @Override
//   public void set(String key, CacheObject value) throws CacheException {
//     try {
//       setByte(key, cacheSerializer.serialize(value),0);
//     } catch (Exception e) {
//       throw new CacheException(key + " serialize error ", e);
//     }
// 
//   }
// 
// 
//   @Override
//   public void set(String key, CacheObject value, int expire) throws CacheException {
// 
//     try {
//       setByte(key, cacheSerializer.serialize(value), expire);
//     } catch (Exception e) {
//       throw new CacheException(key + " serialize error ", e);
//     }
//   }
// 
// 
//   public abstract byte[] getByte(String key) throws CacheException;
// 
//   public abstract void setByte(String key, byte[] value, int seconds) throws CacheException ;
// 
// 
// }
// 
// Path: jbase-cache/src/main/java/com/jayqqaa12/jbase/cache/serializer/CacheSerializer.java
// public interface CacheSerializer {
// 
//     byte[] serialize(Object obj)  ;
// 
//     Object deserialize(byte[] bytes)  ;
// 
// }
// 
// Path: jbase-cache/src/main/java/com/jayqqaa12/jbase/cache/util/CacheException.java
// public class CacheException extends RuntimeException {
// 
//     private static final long serialVersionUID = -5112528854998647834L;
// 
//     public CacheException(String s) {
//         super(s);
//     }
// 
//     public CacheException(String s, Throwable e) {
//         super(s, e);
//     }
// 
//     public CacheException(Throwable e) {
//         super(e);
//     }
// 
// }


import com.jayqqaa12.jbase.cache.provider.SerializerCache;
import com.jayqqaa12.jbase.cache.serializer.CacheSerializer;
import com.jayqqaa12.jbase.cache.util.CacheException;
import io.lettuce.core.api.StatefulConnection;
import io.lettuce.core.api.StatefulRedisConnection;
import io.lettuce.core.api.sync.BaseRedisCommands;
import io.lettuce.core.api.sync.RedisKeyCommands;
import io.lettuce.core.api.sync.RedisStringCommands;
import io.lettuce.core.cluster.api.StatefulRedisClusterConnection;
import org.apache.commons.pool2.impl.GenericObjectPool;
package com.jayqqaa12.jbase.cache.provider.lettuce;



public class LettuceCache extends SerializerCache {

  private final GenericObjectPool<StatefulConnection<String, byte[]>> pool;
  private final String region;
  private final String namespace;

// Path: jbase-cache/src/main/java/com/jayqqaa12/jbase/cache/provider/SerializerCache.java
// public abstract class SerializerCache implements Cache {
// 
//   private final CacheSerializer cacheSerializer;
// 
//   public SerializerCache(CacheSerializer cacheSerializer) {
//     this.cacheSerializer = cacheSerializer;
// 
//   }
// 
//   @Override
//   public CacheObject get(String key) throws CacheException {
//     try {
//       byte[] bytes = getByte(key);
//       return (CacheObject) cacheSerializer.deserialize(bytes);
//     } catch (Exception e) {
//       throw new CacheException(key + " deserialize error ", e);
//     }
//   }
// 
// 
// 
//   @Override
//   public void set(String key, CacheObject value) throws CacheException {
//     try {
//       setByte(key, cacheSerializer.serialize(value),0);
//     } catch (Exception e) {
//       throw new CacheException(key + " serialize error ", e);
//     }
// 
//   }
// 
// 
//   @Override
//   public void set(String key, CacheObject value, int expire) throws CacheException {
// 
//     try {
//       setByte(key, cacheSerializer.serialize(value), expire);
//     } catch (Exception e) {
//       throw new CacheException(key + " serialize error ", e);
//     }
//   }
// 
// 
//   public abstract byte[] getByte(String key) throws CacheException;
// 
//   public abstract void setByte(String key, byte[] value, int seconds) throws CacheException ;
// 
// 
// }
// 
// Path: jbase-cache/src/main/java/com/jayqqaa12/jbase/cache/serializer/CacheSerializer.java
// public interface CacheSerializer {
// 
//     byte[] serialize(Object obj)  ;
// 
//     Object deserialize(byte[] bytes)  ;
// 
// }
// 
// Path: jbase-cache/src/main/java/com/jayqqaa12/jbase/cache/util/CacheException.java
// public class CacheException extends RuntimeException {
// 
//     private static final long serialVersionUID = -5112528854998647834L;
// 
//     public CacheException(String s) {
//         super(s);
//     }
// 
//     public CacheException(String s, Throwable e) {
//         super(s, e);
//     }
// 
//     public CacheException(Throwable e) {
//         super(e);
//     }
// 
// }


// Path: jbase-cache/src/main/java/com/jayqqaa12/jbase/cache/provider/lettuce/LettuceCache.java
import com.jayqqaa12.jbase.cache.provider.SerializerCache;
import com.jayqqaa12.jbase.cache.serializer.CacheSerializer;
import com.jayqqaa12.jbase.cache.util.CacheException;
import io.lettuce.core.api.StatefulConnection;
import io.lettuce.core.api.StatefulRedisConnection;
import io.lettuce.core.api.sync.BaseRedisCommands;
import io.lettuce.core.api.sync.RedisKeyCommands;
import io.lettuce.core.api.sync.RedisStringCommands;
import io.lettuce.core.cluster.api.StatefulRedisClusterConnection;
import org.apache.commons.pool2.impl.GenericObjectPool;

package com.jayqqaa12.jbase.cache.provider.lettuce;



public class LettuceCache extends SerializerCache {

  private final GenericObjectPool<StatefulConnection<String, byte[]>> pool;
  private final String region;
  private final String namespace;

  public LettuceCache(CacheSerializer cacheSerializer, String namespace, String region,