proxy_cache_path /tmp/nginx_team_alert_cache keys_zone=team_alerts:10m levels=1:2 max_size=1g use_temp_path=off;
server{
...
location /api/timeentry/timeentry/team_alerts/ {
proxy_cache team_alerts;
proxy_ignore_headers Cache-Control Set-Cookie;
proxy_hide_header "Set-Cookie";
proxy_cache_valid 200 5s;
proxy_cache_key $scheme$host$request_method$request_uri;
proxy_buffering on;
add_header X-Cached $upstream_cache_status;
include uwsgi_params;
uwsgi_pass unix:/tmp/app.sock;
}
}
我一直在 stackoverflow 等上搜索并添加了所有推荐的选项,但仍然没有缓存。
答案 0 :(得分:0)
我刚刚意识到我是 from numpy import array
import re
def get_num_over_num(value):
match = re.match(r'\d+/\d+', value)
if match:
return match.group(0)
return None
list_2 = ['2/1=MV01', '9/2=MV01C', '13/2=MV01D', '16/1', '25/1=MV02', '36/1 = MV03', '46/1 = MV04', '51/2 = MV05', '56/2 = MV06', '58/1 = MV07', '62/2 = MV08', '68/1', '71/2=MV09', '73/1=MV09A', '75/1=MV09B', '76/1=MV09C', '78/2 = MV10', '79/2 = MV11', '81/2', '84/1', '5/2', '8/1', '42/2', '44/2']
list_2_num_over_nums = set()
for value in list_2:
num_over_num = get_num_over_num(value)
if not num_over_num:
continue
list_2_num_over_nums.add(num_over_num)
list_1 = [array([['0/1']], dtype=object), array([['2/1=MV01']], dtype=object), array([['5/2=MV01A']], dtype=object), array([['8/1=MV01B']], dtype=object), array([['9/2=MV01C']], dtype=object), array([['13/2=MV01D']], dtype=object), array([['16/1']], dtype=object), array([['25/1=MV02']], dtype=object), array([['36/1 = MV03']], dtype=object), array([['42/2']], dtype=object), array([['44/2']], dtype=object), array([['46/1 = MV04']], dtype=object), array([['51/2 = MV05']], dtype=object), array([['56/2 = MV06']], dtype=object), array([['58/1 = MV07']], dtype=object), array([['62/2 = MV08']], dtype=object), array([['68/1']], dtype=object), array([['71/2=MV09']], dtype=object), array([['73/1=MV09A']], dtype=object), array([['75/1=MV09B']], dtype=object), array([['76/1=MV09C']], dtype=object), array([['78/2 = MV10']], dtype=object), array([['79/2 = MV11']], dtype=object), array([['81/2']], dtype=object), array([['84/1']], dtype=object)]
list_1_num_over_nums = set()
list_1_num_over_nums_whole = []
for arr_2dim in list_1:
for arr_1dim in arr_2dim:
for value in arr_1dim:
num_over_num = get_num_over_num(value)
if not num_over_num:
continue
list_1_num_over_nums.add(num_over_num)
# You can also use the whole multi-dimensional array object
if num_over_num not in list_2_num_over_nums:
list_1_num_over_nums_whole.append(arr_2dim)
print("Items in list_1 but not in list_2 (whole object):", list_1_num_over_nums_whole)
print("Items in list_1 but not in list_2:", list_1_num_over_nums - list_2_num_over_nums)
print("Items in list_2 but not in list_1:", list_2_num_over_nums - list_1_num_over_nums)
print("Union of items in list_1 and list_2:", list_1_num_over_nums | list_2_num_over_nums)
print("Intersection of items in list_1 and list_2:", list_1_num_over_nums & list_2_num_over_nums)
print("Items in list_1 or list_2 but not in both:", list_1_num_over_nums ^ list_2_num_over_nums)
所以 Items in list_1 but not in list_2 (whole object): [array([['0/1']], dtype=object)]
Items in list_1 but not in list_2: {'0/1'}
Items in list_2 but not in list_1: set()
Union of items in list_1 and list_2: {'13/2', '0/1', '56/2', '84/1', '73/1', '75/1', '25/1', '58/1', '81/2', '9/2', '79/2', '36/1', '16/1', '51/2', '42/2', '76/1', '5/2', '71/2', '78/2', '2/1', '8/1', '62/2', '68/1', '46/1', '44/2'}
Intersection of items in list_1 and list_2: {'13/2', '56/2', '84/1', '73/1', '75/1', '25/1', '58/1', '81/2', '9/2', '79/2', '36/1', '16/1', '51/2', '76/1', '42/2', '5/2', '71/2', '78/2', '2/1', '8/1', '62/2', '68/1', '46/1', '44/2'}
Items in list_1 or list_2 but not in both: {'0/1'}
指令不起作用,只需将 uwsgi_pass
替换为 proxy_*
工作