Springboot Integrated Redis

Source: Internet
Author: User

about Redis

Redis is a fully open source free and is a high-performance Key-value database.

Redis and other Key-value cache products have the following three features:

    • Redis supports data persistence, which saves data in memory on disk and can be loaded again for use when restarting.

    • Redis not only supports simple key-value types of data, but also provides storage of data such as structural List,set,zset,hash.

    • Redis supports backup of data, that is, Master-slave mode of data backup.

Redis Benefits
    • The performance is very high –redis can read the speed is 110,000 times/s, the write speed is 81,000 times/s.

    • Rich data types –redis support binary case Strings, Lists, hashes, sets and Ordered sets data type operations.

    • All atomic –redis operations are atomic, and Redis supports atomic execution of several operations.

    • Rich features –redis also supports publish/subscribe, notifications, key expiration, and more.

Redis supports five types of data:

String (string), list, set (set), hash (hash), Zset (sorted set-ordered collection)

Installing Redis

Redis has no official version of Windows, but GitHub has a version maintained by the Open source organization
Redis WINDOWS64 bit version
Start commandredis-server.exe redis.windows.conf

maven Dependency
1 <!--redis-->2 <dependency>3     <groupid>org.springframework.boot </groupId>4     <artifactId>spring-boot-starter-redis</artifactId>5 </ Dependency>6 <dependency>7     <groupid>org.springframework.boot</groupid >8     <artifactId>spring-boot-starter-data-redis</artifactId>9 </ Dependency>
Properties Configuration
1 #端口号 2 server.port=806634#redis配置 5 spring.redis.database=16 spring.redis.host=localhost7 spring.redis.port=63798 spring.redis.timeout=3000
unit test class test access
1  Packagecom.example.inchlifc;2 3 Importorg.junit.Test;4 ImportOrg.junit.runner.RunWith;5 Importorg.springframework.beans.factory.annotation.Autowired;6 Importorg.springframework.boot.test.context.SpringBootTest;7 Importorg.springframework.data.redis.core.StringRedisTemplate;8 ImportOrg.springframework.test.context.junit4.SpringRunner;9 Ten@RunWith (Springrunner.class) One @SpringBootTest A  Public classinchlifcapplicationtests { -  - @Autowired the stringredistemplate stringredistemplate; - @Test -     Public voidcontextloads () { -       //Save String +Stringredistemplate.opsforvalue (). Set ("Redistest", "Little Fisherman"); -    } +  A}
Test Results

Springboot Integrated Redis

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.