diff --git a/nginx-1.18.0/logs/access.log b/nginx-1.18.0/logs/access.log index 87fb471..76183e9 100644 --- a/nginx-1.18.0/logs/access.log +++ b/nginx-1.18.0/logs/access.log @@ -14955,3 +14955,46 @@ 127.0.0.1 - - [19/Mar/2025:20:24:58 +0800] "GET /api/shop/1 HTTP/1.1" 200 713 "http://localhost:8080/shop-detail.html?id=1" "Mozilla/5.0 (iPhone; CPU iPhone OS 16_6 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/16.6 Mobile/15E148 Safari/604.1 Edg/134.0.0.0" 127.0.0.1 - - [19/Mar/2025:20:24:58 +0800] "GET /api/voucher/list/1 HTTP/1.1" 200 530 "http://localhost:8080/shop-detail.html?id=1" "Mozilla/5.0 (iPhone; CPU iPhone OS 16_6 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/16.6 Mobile/15E148 Safari/604.1 Edg/134.0.0.0" 127.0.0.1 - - [19/Mar/2025:20:25:00 +0800] "POST /api/voucher-order/seckill/10 HTTP/1.1" 200 53 "http://localhost:8080/shop-detail.html?id=1" "Mozilla/5.0 (iPhone; CPU iPhone OS 16_6 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/16.6 Mobile/15E148 Safari/604.1 Edg/134.0.0.0" +127.0.0.1 - - [20/Mar/2025:15:34:07 +0800] "GET /api/blog/hot?current=1 HTTP/1.1" 200 6065 "http://localhost:8080/" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/134.0.0.0 Safari/537.36 Edg/134.0.0.0" +127.0.0.1 - - [20/Mar/2025:15:34:08 +0800] "GET /api/shop-type/list HTTP/1.1" 499 0 "http://localhost:8080/" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/134.0.0.0 Safari/537.36 Edg/134.0.0.0" +127.0.0.1 - - [20/Mar/2025:15:34:10 +0800] "GET /js/axios.min.map HTTP/1.1" 404 555 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/134.0.0.0 Safari/537.36 Edg/134.0.0.0" +127.0.0.1 - - [20/Mar/2025:15:34:13 +0800] "GET /api/user/me HTTP/1.1" 401 0 "http://localhost:8080/info.html" "Mozilla/5.0 (iPhone; CPU iPhone OS 16_6 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/16.6 Mobile/15E148 Safari/604.1 Edg/134.0.0.0" +127.0.0.1 - - [20/Mar/2025:15:34:13 +0800] "GET /js/axios.min.map HTTP/1.1" 404 555 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/134.0.0.0 Safari/537.36 Edg/134.0.0.0" +127.0.0.1 - - [20/Mar/2025:15:34:13 +0800] "GET /js/axios.min.map HTTP/1.1" 404 555 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/134.0.0.0 Safari/537.36 Edg/134.0.0.0" +127.0.0.1 - - [20/Mar/2025:15:34:21 +0800] "POST /api/user/code?phone=13686869696 HTTP/1.1" 200 27 "http://localhost:8080/login.html" "Mozilla/5.0 (iPhone; CPU iPhone OS 16_6 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/16.6 Mobile/15E148 Safari/604.1 Edg/134.0.0.0" +127.0.0.1 - - [20/Mar/2025:15:34:34 +0800] "POST /api/user/login HTTP/1.1" 200 69 "http://localhost:8080/login.html" "Mozilla/5.0 (iPhone; CPU iPhone OS 16_6 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/16.6 Mobile/15E148 Safari/604.1 Edg/134.0.0.0" +127.0.0.1 - - [20/Mar/2025:15:34:34 +0800] "GET /api/shop-type/list HTTP/1.1" 200 664 "http://localhost:8080/index.html" "Mozilla/5.0 (iPhone; CPU iPhone OS 16_6 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/16.6 Mobile/15E148 Safari/604.1 Edg/134.0.0.0" +127.0.0.1 - - [20/Mar/2025:15:34:34 +0800] "GET /api/blog/hot?current=1 HTTP/1.1" 200 6065 "http://localhost:8080/index.html" "Mozilla/5.0 (iPhone; CPU iPhone OS 16_6 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/16.6 Mobile/15E148 Safari/604.1 Edg/134.0.0.0" +127.0.0.1 - - [20/Mar/2025:15:34:34 +0800] "GET /js/axios.min.map HTTP/1.1" 404 555 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/134.0.0.0 Safari/537.36 Edg/134.0.0.0" +127.0.0.1 - - [20/Mar/2025:15:34:36 +0800] "GET /js/axios.min.map HTTP/1.1" 404 555 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/134.0.0.0 Safari/537.36 Edg/134.0.0.0" +127.0.0.1 - - [20/Mar/2025:15:34:36 +0800] "GET /api/user/me HTTP/1.1" 200 100 "http://localhost:8080/info.html" "Mozilla/5.0 (iPhone; CPU iPhone OS 16_6 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/16.6 Mobile/15E148 Safari/604.1 Edg/134.0.0.0" +127.0.0.1 - - [20/Mar/2025:15:34:36 +0800] "GET /api/blog/of/me HTTP/1.1" 200 673 "http://localhost:8080/info.html" "Mozilla/5.0 (iPhone; CPU iPhone OS 16_6 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/16.6 Mobile/15E148 Safari/604.1 Edg/134.0.0.0" +127.0.0.1 - - [20/Mar/2025:15:34:36 +0800] "GET /api/user/info/1 HTTP/1.1" 200 27 "http://localhost:8080/info.html" "Mozilla/5.0 (iPhone; CPU iPhone OS 16_6 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/16.6 Mobile/15E148 Safari/604.1 Edg/134.0.0.0" +127.0.0.1 - - [20/Mar/2025:15:34:39 +0800] "GET /js/axios.min.map HTTP/1.1" 404 555 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/134.0.0.0 Safari/537.36 Edg/134.0.0.0" +127.0.0.1 - - [20/Mar/2025:15:34:39 +0800] "GET /api/shop-type/list HTTP/1.1" 200 664 "http://localhost:8080/" "Mozilla/5.0 (iPhone; CPU iPhone OS 16_6 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/16.6 Mobile/15E148 Safari/604.1 Edg/134.0.0.0" +127.0.0.1 - - [20/Mar/2025:15:34:39 +0800] "GET /api/blog/hot?current=1 HTTP/1.1" 200 6065 "http://localhost:8080/" "Mozilla/5.0 (iPhone; CPU iPhone OS 16_6 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/16.6 Mobile/15E148 Safari/604.1 Edg/134.0.0.0" +127.0.0.1 - - [20/Mar/2025:15:35:53 +0800] "GET /js/axios.min.map HTTP/1.1" 404 555 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/134.0.0.0 Safari/537.36 Edg/134.0.0.0" +127.0.0.1 - - [20/Mar/2025:15:35:53 +0800] "GET /api/user/me HTTP/1.1" 401 0 "http://localhost:8080/info.html" "Mozilla/5.0 (iPhone; CPU iPhone OS 16_6 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/16.6 Mobile/15E148 Safari/604.1 Edg/134.0.0.0" +127.0.0.1 - - [20/Mar/2025:15:35:53 +0800] "GET /js/axios.min.map HTTP/1.1" 404 555 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/134.0.0.0 Safari/537.36 Edg/134.0.0.0" +127.0.0.1 - - [20/Mar/2025:15:35:55 +0800] "POST /api/user/code?phone=13686869696 HTTP/1.1" 200 27 "http://localhost:8080/login.html" "Mozilla/5.0 (iPhone; CPU iPhone OS 16_6 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/16.6 Mobile/15E148 Safari/604.1 Edg/134.0.0.0" +127.0.0.1 - - [20/Mar/2025:15:36:15 +0800] "POST /api/user/login HTTP/1.1" 200 69 "http://localhost:8080/login.html" "Mozilla/5.0 (iPhone; CPU iPhone OS 16_6 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/16.6 Mobile/15E148 Safari/604.1 Edg/134.0.0.0" +127.0.0.1 - - [20/Mar/2025:15:36:15 +0800] "GET /api/shop-type/list HTTP/1.1" 200 664 "http://localhost:8080/index.html" "Mozilla/5.0 (iPhone; CPU iPhone OS 16_6 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/16.6 Mobile/15E148 Safari/604.1 Edg/134.0.0.0" +127.0.0.1 - - [20/Mar/2025:15:36:15 +0800] "GET /api/blog/hot?current=1 HTTP/1.1" 200 6065 "http://localhost:8080/index.html" "Mozilla/5.0 (iPhone; CPU iPhone OS 16_6 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/16.6 Mobile/15E148 Safari/604.1 Edg/134.0.0.0" +127.0.0.1 - - [20/Mar/2025:15:36:15 +0800] "GET /js/axios.min.map HTTP/1.1" 404 555 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/134.0.0.0 Safari/537.36 Edg/134.0.0.0" +127.0.0.1 - - [20/Mar/2025:20:30:48 +0800] "GET /index.html HTTP/1.1" 304 0 "http://localhost:8080/login.html" "Mozilla/5.0 (iPhone; CPU iPhone OS 16_6 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/16.6 Mobile/15E148 Safari/604.1 Edg/134.0.0.0" +127.0.0.1 - - [20/Mar/2025:20:30:48 +0800] "GET /js/axios.min.map HTTP/1.1" 404 555 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/134.0.0.0 Safari/537.36 Edg/134.0.0.0" +127.0.0.1 - - [20/Mar/2025:20:30:48 +0800] "GET /favicon.ico HTTP/1.1" 200 6343 "http://localhost:8080/index.html" "Mozilla/5.0 (iPhone; CPU iPhone OS 16_6 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/16.6 Mobile/15E148 Safari/604.1 Edg/134.0.0.0" +127.0.0.1 - - [20/Mar/2025:20:30:49 +0800] "GET /api/blog/hot?current=1 HTTP/1.1" 200 6065 "http://localhost:8080/index.html" "Mozilla/5.0 (iPhone; CPU iPhone OS 16_6 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/16.6 Mobile/15E148 Safari/604.1 Edg/134.0.0.0" +127.0.0.1 - - [20/Mar/2025:20:30:49 +0800] "GET /api/shop-type/list HTTP/1.1" 200 664 "http://localhost:8080/index.html" "Mozilla/5.0 (iPhone; CPU iPhone OS 16_6 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/16.6 Mobile/15E148 Safari/604.1 Edg/134.0.0.0" +127.0.0.1 - - [20/Mar/2025:20:30:49 +0800] "GET /js/axios.min.map HTTP/1.1" 404 555 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/134.0.0.0 Safari/537.36 Edg/134.0.0.0" +127.0.0.1 - - [20/Mar/2025:20:30:49 +0800] "GET /api/user/me HTTP/1.1" 401 0 "http://localhost:8080/info.html" "Mozilla/5.0 (iPhone; CPU iPhone OS 16_6 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/16.6 Mobile/15E148 Safari/604.1 Edg/134.0.0.0" +127.0.0.1 - - [20/Mar/2025:20:30:49 +0800] "GET /js/axios.min.map HTTP/1.1" 404 555 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/134.0.0.0 Safari/537.36 Edg/134.0.0.0" +127.0.0.1 - - [20/Mar/2025:20:30:53 +0800] "POST /api/user/code?phone=13686869696 HTTP/1.1" 499 0 "http://localhost:8080/login.html" "Mozilla/5.0 (iPhone; CPU iPhone OS 16_6 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/16.6 Mobile/15E148 Safari/604.1 Edg/134.0.0.0" +127.0.0.1 - - [20/Mar/2025:20:31:02 +0800] "POST /api/user/login HTTP/1.1" 200 69 "http://localhost:8080/login.html" "Mozilla/5.0 (iPhone; CPU iPhone OS 16_6 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/16.6 Mobile/15E148 Safari/604.1 Edg/134.0.0.0" +127.0.0.1 - - [20/Mar/2025:20:31:02 +0800] "GET /api/shop-type/list HTTP/1.1" 200 664 "http://localhost:8080/index.html" "Mozilla/5.0 (iPhone; CPU iPhone OS 16_6 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/16.6 Mobile/15E148 Safari/604.1 Edg/134.0.0.0" +127.0.0.1 - - [20/Mar/2025:20:31:02 +0800] "GET /api/blog/hot?current=1 HTTP/1.1" 200 6065 "http://localhost:8080/index.html" "Mozilla/5.0 (iPhone; CPU iPhone OS 16_6 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/16.6 Mobile/15E148 Safari/604.1 Edg/134.0.0.0" +127.0.0.1 - - [20/Mar/2025:20:31:02 +0800] "GET /js/axios.min.map HTTP/1.1" 404 555 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/134.0.0.0 Safari/537.36 Edg/134.0.0.0" +127.0.0.1 - - [20/Mar/2025:20:31:03 +0800] "GET /js/axios.min.map HTTP/1.1" 404 555 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/134.0.0.0 Safari/537.36 Edg/134.0.0.0" +127.0.0.1 - - [20/Mar/2025:20:31:03 +0800] "GET /api/user/me HTTP/1.1" 200 100 "http://localhost:8080/info.html" "Mozilla/5.0 (iPhone; CPU iPhone OS 16_6 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/16.6 Mobile/15E148 Safari/604.1 Edg/134.0.0.0" +127.0.0.1 - - [20/Mar/2025:20:31:03 +0800] "GET /api/user/info/1 HTTP/1.1" 200 27 "http://localhost:8080/info.html" "Mozilla/5.0 (iPhone; CPU iPhone OS 16_6 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/16.6 Mobile/15E148 Safari/604.1 Edg/134.0.0.0" +127.0.0.1 - - [20/Mar/2025:20:31:03 +0800] "GET /api/blog/of/me HTTP/1.1" 200 673 "http://localhost:8080/info.html" "Mozilla/5.0 (iPhone; CPU iPhone OS 16_6 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/16.6 Mobile/15E148 Safari/604.1 Edg/134.0.0.0" diff --git a/nginx-1.18.0/logs/error.log b/nginx-1.18.0/logs/error.log index e071011..bdf48fb 100644 --- a/nginx-1.18.0/logs/error.log +++ b/nginx-1.18.0/logs/error.log @@ -2855,3 +2855,17 @@ 2025/03/19 20:24:56 [error] 13588#22156: *58 CreateFile() "D:\Program Files\java_program\hm-dianping\nginx-1.18.0/html/hmdp/js/axios.min.map" failed (2: The system cannot find the file specified), client: 127.0.0.1, server: localhost, request: "GET /js/axios.min.map HTTP/1.1", host: "localhost:8080" 2025/03/19 20:24:57 [error] 13588#22156: *64 CreateFile() "D:\Program Files\java_program\hm-dianping\nginx-1.18.0/html/hmdp/js/axios.min.map" failed (2: The system cannot find the file specified), client: 127.0.0.1, server: localhost, request: "GET /js/axios.min.map HTTP/1.1", host: "localhost:8080" 2025/03/19 20:24:58 [error] 13588#22156: *64 CreateFile() "D:\Program Files\java_program\hm-dianping\nginx-1.18.0/html/hmdp/js/axios.min.map" failed (2: The system cannot find the file specified), client: 127.0.0.1, server: localhost, request: "GET /js/axios.min.map HTTP/1.1", host: "localhost:8080" +2025/03/20 15:34:10 [error] 13588#22156: *72 CreateFile() "D:\Program Files\java_program\hm-dianping\nginx-1.18.0/html/hmdp/js/axios.min.map" failed (2: The system cannot find the file specified), client: 127.0.0.1, server: localhost, request: "GET /js/axios.min.map HTTP/1.1", host: "localhost:8080" +2025/03/20 15:34:13 [error] 13588#22156: *72 CreateFile() "D:\Program Files\java_program\hm-dianping\nginx-1.18.0/html/hmdp/js/axios.min.map" failed (2: The system cannot find the file specified), client: 127.0.0.1, server: localhost, request: "GET /js/axios.min.map HTTP/1.1", host: "localhost:8080" +2025/03/20 15:34:13 [error] 13588#22156: *72 CreateFile() "D:\Program Files\java_program\hm-dianping\nginx-1.18.0/html/hmdp/js/axios.min.map" failed (2: The system cannot find the file specified), client: 127.0.0.1, server: localhost, request: "GET /js/axios.min.map HTTP/1.1", host: "localhost:8080" +2025/03/20 15:34:34 [error] 13588#22156: *78 CreateFile() "D:\Program Files\java_program\hm-dianping\nginx-1.18.0/html/hmdp/js/axios.min.map" failed (2: The system cannot find the file specified), client: 127.0.0.1, server: localhost, request: "GET /js/axios.min.map HTTP/1.1", host: "localhost:8080" +2025/03/20 15:34:36 [error] 13588#22156: *86 CreateFile() "D:\Program Files\java_program\hm-dianping\nginx-1.18.0/html/hmdp/js/axios.min.map" failed (2: The system cannot find the file specified), client: 127.0.0.1, server: localhost, request: "GET /js/axios.min.map HTTP/1.1", host: "localhost:8080" +2025/03/20 15:34:39 [error] 13588#22156: *90 CreateFile() "D:\Program Files\java_program\hm-dianping\nginx-1.18.0/html/hmdp/js/axios.min.map" failed (2: The system cannot find the file specified), client: 127.0.0.1, server: localhost, request: "GET /js/axios.min.map HTTP/1.1", host: "localhost:8080" +2025/03/20 15:35:53 [error] 13588#22156: *94 CreateFile() "D:\Program Files\java_program\hm-dianping\nginx-1.18.0/html/hmdp/js/axios.min.map" failed (2: The system cannot find the file specified), client: 127.0.0.1, server: localhost, request: "GET /js/axios.min.map HTTP/1.1", host: "localhost:8080" +2025/03/20 15:35:53 [error] 13588#22156: *93 CreateFile() "D:\Program Files\java_program\hm-dianping\nginx-1.18.0/html/hmdp/js/axios.min.map" failed (2: The system cannot find the file specified), client: 127.0.0.1, server: localhost, request: "GET /js/axios.min.map HTTP/1.1", host: "localhost:8080" +2025/03/20 15:36:15 [error] 13588#22156: *98 CreateFile() "D:\Program Files\java_program\hm-dianping\nginx-1.18.0/html/hmdp/js/axios.min.map" failed (2: The system cannot find the file specified), client: 127.0.0.1, server: localhost, request: "GET /js/axios.min.map HTTP/1.1", host: "localhost:8080" +2025/03/20 20:30:48 [error] 13588#22156: *105 CreateFile() "D:\Program Files\java_program\hm-dianping\nginx-1.18.0/html/hmdp/js/axios.min.map" failed (2: The system cannot find the file specified), client: 127.0.0.1, server: localhost, request: "GET /js/axios.min.map HTTP/1.1", host: "localhost:8080" +2025/03/20 20:30:49 [error] 13588#22156: *105 CreateFile() "D:\Program Files\java_program\hm-dianping\nginx-1.18.0/html/hmdp/js/axios.min.map" failed (2: The system cannot find the file specified), client: 127.0.0.1, server: localhost, request: "GET /js/axios.min.map HTTP/1.1", host: "localhost:8080" +2025/03/20 20:30:49 [error] 13588#22156: *106 CreateFile() "D:\Program Files\java_program\hm-dianping\nginx-1.18.0/html/hmdp/js/axios.min.map" failed (2: The system cannot find the file specified), client: 127.0.0.1, server: localhost, request: "GET /js/axios.min.map HTTP/1.1", host: "localhost:8080" +2025/03/20 20:31:02 [error] 13588#22156: *116 CreateFile() "D:\Program Files\java_program\hm-dianping\nginx-1.18.0/html/hmdp/js/axios.min.map" failed (2: The system cannot find the file specified), client: 127.0.0.1, server: localhost, request: "GET /js/axios.min.map HTTP/1.1", host: "localhost:8080" +2025/03/20 20:31:03 [error] 13588#22156: *116 CreateFile() "D:\Program Files\java_program\hm-dianping\nginx-1.18.0/html/hmdp/js/axios.min.map" failed (2: The system cannot find the file specified), client: 127.0.0.1, server: localhost, request: "GET /js/axios.min.map HTTP/1.1", host: "localhost:8080" diff --git a/src/main/java/com/hmdp/service/impl/VoucherOrderServiceImpl.java b/src/main/java/com/hmdp/service/impl/VoucherOrderServiceImpl.java index 5dc970a..c0b9bea 100644 --- a/src/main/java/com/hmdp/service/impl/VoucherOrderServiceImpl.java +++ b/src/main/java/com/hmdp/service/impl/VoucherOrderServiceImpl.java @@ -11,13 +11,16 @@ import com.hmdp.service.IVoucherOrderService; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.hmdp.service.IVoucherService; import com.hmdp.utils.RedisIdWorker; +import com.hmdp.utils.SimpleRedisLock; import com.hmdp.utils.UserHolder; import org.springframework.aop.framework.AopContext; import org.springframework.aop.framework.AopProxy; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.data.redis.core.StringRedisTemplate; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; +import javax.annotation.Resource; import java.time.LocalDateTime; /** @@ -34,6 +37,8 @@ public class VoucherOrderServiceImpl extends ServiceImpl UNLOCK_SCRIPT; + + // 通过静态代码块,在类初始化的时候就创建了lua脚本 + static { + UNLOCK_SCRIPT = new DefaultRedisScript<>(); + UNLOCK_SCRIPT.setLocation(new ClassPathResource("unlock.lua")); + UNLOCK_SCRIPT.setResultType(Long.class); + } + + + public SimpleRedisLock(String name, StringRedisTemplate stringRedisTemplate) { + this.name = name; + this.stringRedisTemplate = stringRedisTemplate; + } + + @Override + public boolean tryLock(Long timeOutSec) { + // 获取当前线程id + String threadId = ID_PREFIX+Thread.currentThread().getId(); + Boolean succed = stringRedisTemplate.opsForValue().setIfAbsent(KEY_PREFIX + name, threadId , timeOutSec, TimeUnit.SECONDS); + + return Boolean.TRUE.equals(succed); + } + + @Override +// // 这种实现方法不能保证原子性 +// public void unLock() { +// // 释放锁直接删除就好了 +// // 但是直接删除又会存在一个问题,就是有可能删除的不是自己的锁,所以需要判断 +// String threadId = ID_PREFIX+Thread.currentThread().getId(); +// String id = stringRedisTemplate.opsForValue().get(KEY_PREFIX + name); +// if(id.equals(threadId)) { +// stringRedisTemplate.delete(KEY_PREFIX + name); +// } +// } + public void unLock() { + // 调用lua脚本 + stringRedisTemplate.execute( + UNLOCK_SCRIPT, + Collections.singletonList(KEY_PREFIX+name), + ID_PREFIX+Thread.currentThread().getId() + ); + } +} diff --git a/src/main/resources/unlock.lua b/src/main/resources/unlock.lua new file mode 100644 index 0000000..d057e44 --- /dev/null +++ b/src/main/resources/unlock.lua @@ -0,0 +1,15 @@ +--- +--- Generated by EmmyLua(https://github.com/EmmyLua) +--- Created by fang. +--- DateTime: 2025/3/21 16:27 +--- + +--- 获取redis中存的id + +--- 获取UUID+当前线程id,通过参数传进来 +if(redis.call("get", KEYS[1])==ARGV[1]) then + --- 一致删除锁,并放回1 + return redis.call("del", KEYS[1]) +end +--- 不一致返回0 +return 0