redis java配置

简述:

redis后台仓储配置


步骤:

1. 下载后台service压缩文件

https://github.com/dmajkic/redis/downloads


2. java所需的jar包

https://github.com/xetorthio/jedis/downloads


3. 下载后,打开server.exe

redis java配置_第1张图片


3. 此时会出现一个cmmand面板,让这个command开着

redis java配置_第2张图片


4. 在代码中实际测试,默认端口6379

public class JedisCache {
	// 创建Jedis存储
	private static ShardedJedis jedis;
	static {
		List<JedisShardInfo> shards = new ArrayList<JedisShardInfo>();
		JedisShardInfo si = new JedisShardInfo("localhost", 6379);
		shards.add(si);
		jedis = new ShardedJedis(shards);
	}
	
	
	public static ShardedJedis getJedis(){
		return jedis;
	}
}


插入jedis的map中(string, string)

		final String id = "1";
		String value = "value";
		JedisCache.getJedis().set(id, value);



你可能感兴趣的:(redis java配置)