package org.onetwo.boot.module.redis;

import lombok.Data;
import lombok.EqualsAndHashCode;

import org.onetwo.common.utils.LangOps;
import org.springframework.boot.context.properties.ConfigurationProperties;

/**
 * @author wayshall
 * <br/>
 */
@ConfigurationProperties("jfish.redis")
@EqualsAndHashCode(callSuper=false)
@Data
public class JFishRedisProperties {

	public static final String ENABLED_KEY = "jfish.redis.enabled";
	public static final String SERIALIZER_KEY = "jfish.redis.serializer";
	public static final String ENABLED_LOCK_REGISTRY = "jfish.redis.lockRegistry.key";

	/*String hostName = "localhost";
	int port = Protocol.DEFAULT_PORT;
	int timeout = Protocol.DEFAULT_TIMEOUT;
	String password;
	boolean usePool = true;
	int dbIndex = 0;
	boolean convertPipelineAndTxResults = true;
	JedisPoolConfig pool;*/
	
	OnceTokenProperties onceToken = new OnceTokenProperties();
	LockRegistryProperties lockRegistry = new LockRegistryProperties();
	
	/*public String getHostName() {
		return hostName;
	}*/
	
	@Data
	public static class LockRegistryProperties {
		String key;
		long expireAfter = 60000;
		
		public String getKey(){
			return key;
		}
	}
	
	@Data
	public static class OnceTokenProperties {
	    private String expiredTime = "2m";
	    private String prefix = "once-token:";
	    
	    public int getExpiredInSeconds(){
	    	return (int)LangOps.timeToSeconds(expiredTime, 120);
	    }
		
	}
}

@@ -36,62 +36,8 @@
 s;%0A%0A
-import lombok.Data;%0Aimport lombok.EqualsAndHashCode;%0A%0A
 impo
@@ -72,16 +72,16 @@
 angOps;%0A
+
 import o
@@ -149,16 +149,70 @@
 rties;%0A%0A
+import lombok.Data;%0Aimport lombok.EqualsAndHashCode;%0A%0A
 /**%0A * @
@@ -578,16 +578,83 @@
 ry.key%22;
+%0A%09private static final String LOCK_PREFX_KEY = %22Zifish:RedisLock:%22;
 %0A%0A%09/*Str
@@ -1204,16 +1204,16 @@
 tKey()%7B%0A
-
 %09%09%09retur
@@ -1213,16 +1213,33 @@
 %09%09return
+ LOCK_PREFX_KEY +
  key;%0A%09%09

add redis lock key prefix