服务发布(无redis版)
This commit is contained in:
@ -18,12 +18,12 @@ mybatis.type-aliases-package=com.bipt.intelligentapplicationorchestrationservice
|
||||
mybatis.configuration.map-underscore-to-camel-case=true
|
||||
|
||||
# Redis服务器地址
|
||||
spring.data.redis.host=localhost
|
||||
spring.data.redis.host=116.205.121.200
|
||||
# Redis服务器端口
|
||||
spring.data.redis.port=6379
|
||||
# Redis密码(如果有)
|
||||
spring.data.redis.password=123456
|
||||
spring.data.redis.password=Jbjhhzstsl97@
|
||||
# Redis数据库索引(默认为0)
|
||||
spring.data.redis.database=2
|
||||
spring.data.redis.database=0
|
||||
# 连接超时时间(毫秒)
|
||||
spring.data.redis.timeout=3000
|
||||
|
@ -0,0 +1,53 @@
|
||||
package com.bipt.intelligentapplicationorchestrationservice;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.data.redis.core.*;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
@SpringBootTest
|
||||
public class RedisTest {
|
||||
|
||||
@Autowired
|
||||
private RedisTemplate redisTemplate;
|
||||
|
||||
@Test
|
||||
public void testRedisTemplate(){
|
||||
System.out.println(redisTemplate);
|
||||
ValueOperations valueOperations = redisTemplate.opsForValue();
|
||||
HashOperations hashOperations = redisTemplate.opsForHash();
|
||||
ListOperations listOperations = redisTemplate.opsForList();
|
||||
SetOperations setOperations = redisTemplate.opsForSet();
|
||||
ZSetOperations zSetOperations = redisTemplate.opsForZSet();
|
||||
}
|
||||
@Test
|
||||
public void testString(){
|
||||
//set get setex setnx
|
||||
redisTemplate.opsForValue().set("name","小明");
|
||||
String city =(String) redisTemplate.opsForValue().get("name");
|
||||
System.out.println(city);
|
||||
redisTemplate.opsForValue().set("code","1234",3, TimeUnit.MINUTES);
|
||||
redisTemplate.opsForValue().setIfAbsent("lock","1");
|
||||
redisTemplate.opsForValue().setIfAbsent("lock","2");
|
||||
}
|
||||
@Test
|
||||
public void testHash(){
|
||||
// hset hget hdel hkeys hvals
|
||||
HashOperations hashOperations = redisTemplate.opsForHash();
|
||||
hashOperations.put("100","name","tom");
|
||||
hashOperations.put("100","age","20");
|
||||
|
||||
String name = (String) hashOperations.get("100", "name");
|
||||
System.out.println(name);
|
||||
|
||||
Set keys = hashOperations.keys("100");
|
||||
System.out.println(keys);
|
||||
List values = hashOperations.values("100");
|
||||
System.out.println(values);
|
||||
hashOperations.delete("100","age");
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user