Redis Learning Java Redis applications

Source: Internet
Author: User
Tags download redis redis tutorial

A summary of learning Redis: http://www.runoob.com/redis/redis-tutorial.html http://www.redis.cn/One is a rookie website, one is the Redis Chinese web can be learned

Here's a summary of what you learned about Redis, but the simple primer is used for just the record:

window: Download Redis, via cmd command line entry: Execute redis-server start server, then execute REDIS-CLI start client to operate the specific commands can be learned from the above Web site, the first time to learn what Time is his use of the scene is the use of frequent CPU or IO Read and write resource-consuming bar ...

Linux: Because the purchase of the operating system has been installed in the direct REDIS-CLI can be as if the client server should be started, if you restart the service redis-server restart

Remote connection when the use of the command: redis-cli-h 127.0.0.1-p 6379-a Password = = Explanation:-H host-P Port-a password if there is no password by default, you do not have to enter, but the debugging has not been successful there may be problems with the system settings should be Firewall off Google search for a sudo iptables-f a comparison pit command to delete all rules, the pit of the SSH database what can not be remote access, so here to remind everyone must be cautious operation iptables Command finally no way service iptables Stop config iptables off completely shut down the firewall to resolve

Manipulating the List command is an interesting phenomenon:

Lpush List1 Value value1 value 2 value3

List1 There is a total of four data to view the words:
Lrange List 0 3
The results are reversed. value3 value2 value1 Value

Java redis app: Download Jedis.jar. Then you can make a call to the Redis command.

 PackageRedis;ImportJava.util.Iterator;Importjava.util.List;ImportJava.util.Set;ImportRedis.clients.jedis.Jedis; Public classRedis { Public Static voidMain (string[] args) {//Connect to a local Redis serviceJedis Jedis =NewJedis ("localhost"); System.out.println ("Connection to Server sucessfully"); //setting up Redis string DataJedis.set ("Runoobkey", "Redis Tutorial"); Jedis.set ("A", "A1"); Jedis.set ("B", "B1"); Jedis.set ("C", "C1"); Jedis.set ("D", "D1"); //get the stored data and outputSystem.out.println ("Stored string in Redis::" + jedis.get ("Runoobkey")); System.out.println ("==================================="); Jedis.lpush ("Tutorial-list", "Redis"); Jedis.lpush ("Tutorial-list", "Mongodb"); Jedis.lpush ("Tutorial-list", "Mysql"); //get the stored data and outputlist<string> list = Jedis.lrange ("Tutorial-list", 0, 5);  for(inti=0; I<list.size (); i++) {System.out.println ("Stored string in Redis::" +List.get (i)); } Set<String> list1 =jedis.keys ("*"); Iterator<String> ite=List1.iterator ();  while(Ite.hasnext ()) {System.out.println ("This is key======:" +Ite.next ());         } jedis.flushall (); }}

Redis learning Java Redis app

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.