|
@@ -1,20 +1,36 @@
|
|
|
package com.example.demo1;
|
|
|
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
|
+import org.springframework.data.redis.core.ValueOperations;
|
|
|
import org.springframework.web.bind.annotation.GetMapping;
|
|
|
+import org.springframework.web.bind.annotation.RequestAttribute;
|
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
import org.springframework.web.bind.annotation.RestController;
|
|
|
|
|
|
+import java.util.Date;
|
|
|
+import java.util.concurrent.TimeUnit;
|
|
|
+
|
|
|
|
|
|
@RestController
|
|
|
public class TestController {
|
|
|
|
|
|
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private ValueOperations<String, Object> valueOperations;
|
|
|
+
|
|
|
|
|
|
@RequestMapping("/getName")
|
|
|
@GetMapping
|
|
|
- public String getUsernam(){
|
|
|
+ public String getUsernam(@RequestAttribute String subject)
|
|
|
+ {
|
|
|
+
|
|
|
+ valueOperations.setIfAbsent("ttt_89871" , true, 20, TimeUnit.MINUTES);
|
|
|
+ valueOperations.set("code_09121", new Date(), 30000, TimeUnit.SECONDS);
|
|
|
+ Date dateCurr= (Date)valueOperations.get("code_09121");
|
|
|
+ System.out.println(dateCurr);
|
|
|
+ System.out.println("subject:"+subject);
|
|
|
return "111";
|
|
|
}
|
|
|
|