redis windows 下載地址:https://github.com/ServiceStack/redis-windowsjava
1、下載的安裝包解壓到盤符的指定位置,以下結構:(純手敲,若是有缺失,見諒)git
Redis.docgithub
redis-benchmark.exeredis
redis-check-aop.exewindows
redis-check-dump.exe服務器
redis-cli.exe測試
RedisQFork_8524.datspa
redis-server.execode
RedisService.docserver
個人安裝路徑:D:\install_tool\redis\redis64-2.8.9
2、使用windows dos窗口
打開到安裝路徑,執行此命令:redis-server redis.windows.conf
若是出現一個圖形界面,
_._
_.-``__ ''-._
_.-`` `. `_. ''-._ Redis 2.8.9 (00000000/0) 64 bit
.-`` .-```. ```\/ _.,_ ''-._
( ' , .-` | `, ) Running in stand alone mode
|`-._`-...-` __...-.``-._|'` _.-'| Port: 6379
| `-._ `._ / _.-' | PID: 8524
`-._ `-._ `-./ _.-' _.-'
|`-._`-._ `-.__.-' _.-'_.-'|
| `-._`-._ _.-'_.-' | http://redis.io
`-._ `-._`-.__.-'_.-' _.-'
|`-._`-._ `-.__.-' _.-'_.-'|
| `-._`-._ _.-'_.-' |
`-._ `-._`-.__.-'_.-' _.-'
`-._ `-.__.-' _.-'
`-._ _.-'
`-.__.-'
[8524] 07 Aug 14:41:49.229 # Server started, Redis version 2.8.9
[8524] 07 Aug 14:41:49.230 * The server is now ready to accept connections on po
rt 6379
則表示啓動redis服務成功。雙擊,redis-cli.exe客戶端,測試,輸入,set age 21 回車,下一行,get age回車,若是輸出21,就說明你安裝redis成功。
redis-客戶端 jedis實現分片存放數據:
首先須要下載jar,pom文件以下:
<!-- jedis -->
<dependency>
<groupId>redis.clients</groupId>
<artifactId>jedis</artifactId>
<version>2.7.3</version>
<name>Jedis</name>
</dependency>
package com.liyi.test.redis; import java.util.ArrayList; import java.util.List; import redis.clients.jedis.JedisPoolConfig; import redis.clients.jedis.JedisShardInfo; import redis.clients.jedis.ShardedJedis; import redis.clients.jedis.ShardedJedisPool; public class RedisShardPoolTest { //redis鏈接池 static ShardedJedisPool pool; static{ //redis服務器列表 這裏能夠設置多個redis服務器的地址和端口 String hostA ="127.0.0.1"; int port1 =6379; List<JedisShardInfo> jdsInfoList =new ArrayList<JedisShardInfo>(); JedisShardInfo jedis1 = new JedisShardInfo(hostA, port1); jdsInfoList.add(jedis1); //池基本配置 JedisPoolConfig config = new JedisPoolConfig(); config.setMaxIdle(1000 * 60);//對象最大空閒時間 config.setTestOnBorrow(true); pool=new ShardedJedisPool(config, jdsInfoList); } public static void main(String[] args) { ShardedJedis redis = pool.getResource(); redis.set("name", "liyi"); pool.returnResource(redis); } }
啓動redis的服務器,而後在打開redis的客戶端dos窗口:
輸入 get name
若是出現如下結果你就成功了
127.0.0.1:6379> get name
"liyi"
windows——>redis經常使用命令:
查詢redis中全部的key:keys *
查詢redis是否存在key:exists key
刪除redis中的key:del key
獲取鍵值的數據類型: type key
清除redis服務器的數據:
select 0
flushall
flushdb