[AppleScript] 纯文本查看 复制代码
@SpringBootTest @RunWith(SpringRunner.class) public class RedisTest {
@Autowired
private StringRedisTemplate stringRedisTemplate;
@Test
public void testRedis(){
//定义key
String key = "user_token:9734b68f‐cf5e‐456f‐9bd6‐df578c711390";
//定义Map
Map<String,String> mapValue = new HashMap<>();
mapValue.put("id","101");
mapValue.put("username","itcast");
String value = JSON.toJSONString(mapValue);
//向redis中存储字符串
stringRedisTemplate.boundValueOps(key).set(value,60, TimeUnit.SECONDS);
//读取过期时间,已过期返回‐2
Long expire = stringRedisTemplate.getExpire(key);
//根据key获取value
String s = stringRedisTemplate.opsForValue().get(key);
System.out.println(s);
} }
[AppleScript] 纯文本查看 复制代码
@Api(value = "用户认证",description = "用户认证接口") public interface AuthControllerApi {
@ApiOperation("登录")
public LoginResult login(LoginRequest loginRequest);
@ApiOperation("退出")
public ResponseResult logout(); }