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