Redis Data Summary (i) Environment construction

Source: Internet
Author: User

1. Introduction

Redis is an open-source key-value database. It is also often considered a data structure server. Because its value includes not only the basic string type but also the List,set, sorted set and hash type. Of course, these types of elements are also string types. That is, list,set these collection types can also contain only string types. You can do a lot of atomic manipulation on these types. For example, append a string to a character value (Append command). Gaga or subtract a numeric string (the INCR command, of course, is processed by integers). You can push the list type, or the pop element operation (which can simulate stacks and queues). Some set-related operations can be performed for set types (intersection union difference). Memcache also has commands similar to,--with + +.

However, the value of Memcache only includes the string type. Far from Redis, the value type is rich. As with Memcahe for performance. Redis data is usually put into memory. Of course, Redis can write in-memory data to disk for a certain amount of time every interval to prevent data loss. Redis also supports the master-slave replication mechanism (Master-slave replication). Other features of Redis include simple transactional support and publish-subscribe (PUB/SUB) channel functionality, and Redis configuration management is straightforward. There are also various language versions of the open source client class library.

2. installation

: http://redis.googlecode.com/files/redis-2.0.4.tar.gz

2.0 is currently the latest stable version

You can run the following command under Linux to install

$ tar xzf redis-2.0.4.tar.gz
$ CD redis-2.0.4
$
Make

After make the redis-2.0.4 directory will appear after the compiled Redis service program Redis-server, as well as the client program for testing REDIS-CLI

Start the Redis service below.

$./redis-server

Note this way of starting Redis is using the default configuration. You can also tell Redis to start with the following command using the specified configuration file through the startup parameters.

$./redis-server redis.conf

Redis.conf is a default configuration file. We can use our own configuration files as needed.

Once the Redis service process is started, you can use the test client program REDIS-CLI to interact with the Redis service.

Like what

$./redis-cli
Redis> set Foo Bar
Ok
Redis> get foo
"Bar"

This shows an example of the get and set commands manipulating simple type value. Foo is a key, bar is a string type of value

No Linux can be practiced through this online, of course, the online version of the many management-related commands are not supported.

http://try.redis-db.com/

3 . Java Client Hello,world

Client jar package Address Http://cloud.github.com/downloads/alphazero/jredis/jredis-1.0-rc2.jar. The version is currently a bit old and supports Redis 1.2.6. The latest version of 2.0 hasn't been release yet.
Create a new Java project in Eclipse and add the Jredis package reference. Here's a hello,world program.

1234567891011121314151617181920212223 package jredisStudy;import org.jredis.*;import org.jredis.ri.alphazero.JRedisClient;public class App {    public static void main(String[] args) {        try {            JRedis jr = new JRedisClient("192.168.56.55", 6379); //redis服务地址和端口号            String key = "mKey";            jr.set(key, "hello,redis!");            String v = new String(jr.get(key));            String k2 = "count";            jr.incr(k2);            jr.incr(k2);            System.out.println(v);            System.out.println(new String(jr.get(k2)));        } catch (Exception e) {            // TODO: handle exception        }    }}

Okay, the REDIS environment is ready. The various types and types of Redis-related commands and some specific scenarios are written later

Http://www.cnblogs.com/xhan/archive/2011/02/01/1948751.html

Redis Data Summary (i) Environment construction

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.