Explorar o código

캐싱 방법 변경

Surplus_Up (2DU) %!s(int64=6) %!d(string=hai) anos
pai
achega
b10ccda4ec
Modificáronse 4 ficheiros con 12 adicións e 12 borrados
  1. 1 1
      app.py
  2. 0 2
      route/tool/func.py
  3. 9 7
      route/view_read.py
  4. 2 2
      version.json

+ 1 - 1
app.py

@@ -169,7 +169,7 @@ except:
 
 if setup_tool != 0:
     create_data['data'] = ['title', 'data']
-    create_data['cache_data'] = ['title', 'data']
+    create_data['cache_data'] = ['title', 'data', 'id']
     create_data['history'] = ['id', 'title', 'data', 'date', 'ip', 'send', 'leng', 'hide', 'type']
     create_data['rd'] = ['title', 'sub', 'date', 'band', 'stop', 'agree']
     create_data['user'] = ['id', 'pw', 'acl', 'date', 'encode']

+ 0 - 2
route/tool/func.py

@@ -1032,8 +1032,6 @@ def rd_plus(title, sub, date):
     conn.commit()
 
 def history_plus(title, data, date, ip, send, leng, t_check = '', d_type = ''):
-    curs.execute(db_change("delete from cache_data where title = ?"), [title])
-
     curs.execute(db_change("select id from history where title = ? and type = '' order by id + 0 desc limit 1"), [title])
     id_data = curs.fetchall()
     id_data = str(int(id_data[0][0]) + 1) if id_data else '1'

+ 9 - 7
route/view_read.py

@@ -75,13 +75,13 @@ def view_read_2(conn, name):
 
         curs.execute(db_change("select data from history where title = ? and id = ?"), [name, str(num)])
     else:
-        if not flask.request.args.get('reload', None):
-            curs.execute(db_change("select data from cache_data where title = ?"), [name])
+        curs.execute(db_change("select id from history where title = ? order by id + 0 desc limit 1"), [name])
+        last_history_num = curs.fetchall()
+        if last_history_num and not flask.request.args.get('reload', None):
+            curs.execute(db_change("select data from cache_data where title = ? and id = ?"), [name, last_history_num[0][0]])
             cache_data = curs.fetchall()
-            if not cache_data or cache_data[0][0] == 'HTTP Request 404':
+            if not cache_data:
                 curs.execute(db_change("select data from data where title = ?"), [name])
-                
-                cache_data = None
         else:
             curs.execute(db_change("select data from data where title = ?"), [name])
 
@@ -108,8 +108,10 @@ def view_read_2(conn, name):
             data = else_data
         )
 
-        curs.execute(db_change("delete from cache_data where title = ?"), [name])
-        curs.execute(db_change("insert into cache_data (title, data) values (?, ?)"), [name, end_data])
+        if not num:
+            curs.execute(db_change("delete from cache_data where title = ?"), [name])
+            if last_history_num:
+                curs.execute(db_change("insert into cache_data (title, data, id) values (?, ?, ?)"), [name, end_data, last_history_num[0][0]])
 
     if end_data == 'HTTP Request 401.3':
         response_data = 401

+ 2 - 2
version.json

@@ -1,7 +1,7 @@
 {
     "master" : {
-        "r_ver" : "v3.1.6-master-31",
-        "c_ver" : "3160028",
+        "r_ver" : "v3.1.6-master-32",
+        "c_ver" : "3160032",
         "s_ver" : "7"
     }, "stable" : {
         "r_ver" : "v3.1.5-stable-03",