package nc.th.redistoken;

import redis.clients.jedis.Jedis;

public class RedisTokenManager {
	private static final String REDIS_HOST = "127.0.0.1";

	private static final int REDIS_PORT = 6379;

	private static final int REDIS_DB = 0;

	private static Jedis jedis = new Jedis(REDIS_HOST, REDIS_PORT);
	
	//设置token永久
	public static void setToken(String userId, String token) {

		jedis.set(userId, token);

	}

	//获取token
	public static String getToken(String userId) {

		return jedis.get(userId);

	}
		
	//设置token失效时间秒	
	public static void setTokenTTL(String userId,int seconds, String token) {

		jedis.setex(userId, seconds, token);

	}
	
	
}
