Graphical installation of Redis under Windows _redis

Source: Internet
Author: User
Tags delete key hash memcached redis sleep install redis

Redis is a key-value storage system. Like memcached, it supports a relatively greater number of stored value types, including string (string), list (linked list), set (set), Zset (sorted set-ordered set), and hash (hash type). These data types support Push/pop, Add/remove and intersection-set and differential sets and richer operations, and these operations are atomic. On this basis, Redis supports a variety of different ways of ordering. As with memcached, data is cached in memory to ensure efficiency. The difference is that Redis periodically writes the updated data to the disk or writes the modification operation to the appended record file, and realizes the master-slave on this basis.

Because it is the first time to use, so it is installed and used under Windows, reference several blog, the following collation:

1. Install Redis

Official website: http://redis.io/

Official downloads: Http://redis.io/download can download different versions as needed

Windows version: Https://github.com/mythz/redis-windows

GitHub resources can be downloaded directly (this is for the students do not know the friendship hint).

After the download is complete, you can extract the right key to a hard drive such as D:\Redis\redis-2.6.

Under D:\Redis\redis-2.6\bin\release, there are two zip packages with a 32-bit 64 bit.

Extract the number of bits from your windows to the D:\Redis\redis-2.6 root directory.

2. Start Redis

Open service after entering Redis directory (note plus redis.conf)

Redis-server.exe redis.conf
The Redis service automatically shuts down when this window is to be turned on and off

Redis will automatically save data to the hard disk so the second time I opened it, I had a DB loaded from disk

3. Test use

In addition, open a command line window into the Redis directory (note to modify your own IP)

 
 

4.Java Development Package Jedis

Jedis:redis's official Preferred Java Development Kit

<!--redis--> 
<dependency> 
<groupId>redis.clients</groupId> 
<artifactid >jedis</artifactId> 
<version>2.0.0</version> 
<type>jar</type> 
<scope>compile</scope> 
Package com.lujianing.utils; 
Import Org.junit.Before; 
Import Org.junit.Test; 
Import Redis.clients.jedis.Jedis; 
Import Redis.clients.jedis.JedisPool; 
Import Redis.clients.jedis.JedisPoolConfig; 
Import Java.util.HashMap; 
Import Java.util.Iterator; 
Import java.util.List; 
Import Java.util.Map; 
/** * Created by lujianing on 14-2-28. 
* * public class Jedisutiltest {Jedispool pool; 
Jedis Jedis; 
@Before public void SetUp () {pool = new Jedispool (new Jedispoolconfig (), "192.168.10.61"); 
Jedis = Pool.getresource (); 
Jedis.auth ("password"); 
@Test public void Testget () {System.out.println (Jedis.get ("Lu")); /** * Redis Store the primary string * CRUD/@Test public void testbasicstring () {//-----Add Data----------jedis.set ("name", "MINXR //To Key-->name VALUE--&GT;MINXR System.out.println (jedis.get ("name"));/execution Result: MINXR//-----  Modify the data-----------//1, modify jedis.append on the original basis ("name", "Jarorwar"); Very intuitive, similar to map will Jarorwar append to the existing value after System.out.println (Jedis.get ("name"))//Execution Result: Minxrjarorwar//2, directly overwrite the original data jedis.set ("name", "Min Xiaorong"); 
System.out.println (Jedis.get ("name")),//Execution Result: Min Xiaorong//delete key corresponding record Jedis.del ("name"); 
System.out.println (Jedis.get ("name"))//execution result: null/** * mset equivalent to * jedis.set ("name", "MINXR"); 
* Jedis.set ("Jarorwar", "Min Xiaorong");      
* * Jedis.mset ("name", "MINXR", "Jarorwar", "Min Xiaorong"); 
System.out.println (Jedis.mget ("name", "Jarorwar"));  
/** * Jedis Operation MAP */@Test public void TestMap () {map<string,string> user=new hashmap<string,string> (); 
User.put ("name", "MINXR"); 
User.put ("pwd", "password"); 
Jedis.hmset ("user", user); 
Remove name from user, execute result:[minxr]--> Note The result is a generic list//The first parameter is the key to the Map object in the Redis, followed by the key to the object in the map, followed by the key can be with multiple, is a variable parameter 
list<string> Rsmap = jedis.hmget ("User", "name"); 
System.out.println (RSMAP); 
Deletes a key value//Jedis.hdel ("User", "pwd") in the map; System.out.println (Jedis.hmget ("User", "pwd")); Because it was deleted, it returns a null System.out.println (Jedis.hlen ("user")); Returns the number of values stored in the key for user 1 System.out.println (jedis.exIsts ("user"));/whether there is a record that the key is user returns True System.out.println (Jedis.hkeys ("user");//returns all key [PWD, name] in the Map object System.out.println (jedis.hvals ("user"))//Return all value in Map object [MINXR, password] iterator<string> iter= 
Jedis.hkeys ("user"). iterator ();        while (Iter.hasnext ()) {String key = Iter.next (); 
System.out.println (key+ ":" +jedis.hmget ("User", key)); 
}/** * Jedis operation list/@Test public void Testlist () {//before starting, remove all content Jedis.del ("Java framework"); 
System.out.println (Jedis.lrange ("Java framework", 0,-1)); 
First, store three data Jedis.lpush ("Java framework", "Spring") into the key Java framework; 
Jedis.lpush ("Java framework", "struts"); 
Jedis.lpush ("Java framework", "Hibernate"); And then remove all the data jedis.lrange is removed by range,//The first is the key, the second is the starting position, the third is the end position, and the Jedis.llen gets the length 1 to obtain all SYSTEM.OUT.PRINTLN (Jedis.lrange ( 
"Java framework", 0,-1)); 
/** * Jedis Operation set */@Test public void Testset () {//Add Jedis.sadd ("Sname", "MINXR"); 
Jedis.sadd ("Sname", "Jarorwar"); 
Jedis.sadd ("Sname", "Min Xiaorong"); Jedis.sadd ("Sanme", "Noname"); 
Removal of Noname Jedis.srem ("sname", "Noname"); System.out.println (Jedis.smembers ("sname"))//Get all added value System.out.println (Jedis.sismember ("sname", "MINXR")) 
//To determine whether MINXR is the element of the sname set System.out.println (Jedis.srandmember ("sname")); System.out.println (Jedis.scard ("sname"))//Returns the number of elements of the collection} @Test public void Test () throws Interruptedexception {//keys The wildcard character System.out.println (Jedis.keys ("*")) can be passed in. Returns all key [Sose, Sanme, name, Jarorwar, foo, sname, Java Framework, user, Braand] System.out.println in the current library (Jedis.keys ("*na 
ME))//Return sname [sname, name] System.out.println (Jedis.del ("Sanmdde"));/delete key for Sanmdde object Delete successfully return 1 delete failed (or does not exist) return 0 System.out.println (Jedis.ttl ("sname"))//Returns the valid time of the given key, if-1 means forever valid Jedis.setex ("TimeKey", "min");  You can specify that the key's surviving (active time) time is seconds Thread.Sleep (5000), and/or 5 seconds after sleep, the remaining time will be <=5 System.out.println (Jedis.ttl ("TimeKey"));    The output result is 5 Jedis.setex ("TimeKey", 1, "min"); Set to 1, the rest of the time to look at is 1 System.out.println (Jedis.ttl ("TimeKey")); Output is 1 System. OUT.PRINTLN (Jedis.exists ("key"))/check key for System.out.println (Jedis.rename ("TimeKey", "Time"); System.out.println (Jedis.get ("TimeKey"));//Because of removal, return to null System.out.println (Jedis.get ("Time")); Because the TimeKey is renamed to time, you can get the value min//jedis sort//Note that the Rpush and Lpush here are the operations of the list. 
is a two-way linked list (but from the performance point of view) Jedis.del ("a");//First clear the data, then add the data to test Jedis.rpush ("A", "1"); 
Jedis.lpush ("A", "6"); 
Jedis.lpush ("A", "3"); 
Jedis.lpush ("A", "9"); System.out.println (Jedis.lrange ("a", 0,-1));//[9, 3, 6, 1] System.out.println (Jedis.sort ("a")); 
[1, 3, 6, 9]//Input sort result System.out.println (Jedis.lrange ("a", 0,-1));  } 
}

Redis will periodically save the data to the hard drive

The above is a small set for everyone to share in Windows for installation and use of Redis skills, I hope to be proficient in Windows under the Redis of the installation of the use of help.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.