Przeglądaj źródła

캐싱 기능 적용

Surplus_Up (2DU) 6 lat temu
rodzic
commit
bc6a391f0b
4 zmienionych plików z 33 dodań i 20 usunięć
  1. 1 1
      route/setting.py
  2. 2 0
      route/tool/func.py
  3. 29 18
      route/view_read.py
  4. 1 1
      version.json

+ 1 - 1
route/setting.py

@@ -161,7 +161,7 @@ def setting_2(conn, num):
                         <select name="skin">''' + load_skin(d_list[5]) + '''</select>
                         <hr>
                         <input type="checkbox" name="reg" ''' + check_box_div[0] + '''> ''' + load_lang('no_register') + '''
-                        <hr>
+                        <hr class=\"main_hr\">
                         <input type="checkbox" name="ip_view" ''' + check_box_div[1] + '''> ''' + load_lang('hide_ip') + '''
                         <hr class=\"main_hr\">
                         <input type="checkbox" name="email_have" ''' + check_box_div[2] + '''> ''' + load_lang('email_required') + ' <a href="/setting/6">(' + load_lang('smtp_setting_required') + ''')</a>

+ 2 - 0
route/tool/func.py

@@ -1059,6 +1059,8 @@ 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'

+ 29 - 18
route/view_read.py

@@ -72,29 +72,40 @@ def view_read_2(conn, name):
         if curs.fetchall() and admin_check(6) != 1:
             return redirect('/history/' + url_pas(name))
 
-        curs.execute(db_change("select title, data from history where title = ? and id = ?"), [name, str(num)])
+        curs.execute(db_change("select data from history where title = ? and id = ?"), [name, str(num)])
     else:
-        curs.execute(db_change("select title, data from data where title = ?"), [name])
-
-    data = curs.fetchall()
-    if data:
-        else_data = data[0][1]
+        curs.execute(db_change("select data from cache_data where title = ?"), [name])
+        cache_data = curs.fetchall()
+        if not cache_data or cache_data[0][0] == 'HTTP Request 404':
+            curs.execute(db_change("select data from data where title = ?"), [name])
+            cache_data = None
+
+    if cache_data:
+        end_data = cache_data[0][0]
     else:
-        else_data = None
+        data = curs.fetchall()
+        print(data)
+        if data:
+            else_data = data[0][0]
+        else:
+            else_data = None
+
+        curs.execute(db_change("select decu from acl where title = ?"), [name])
+        data = curs.fetchall()
+        if data:
+            acl = 1
 
-    curs.execute(db_change("select decu from acl where title = ?"), [name])
-    data = curs.fetchall()
-    if data:
-        acl = 1
+        if flask.request.args.get('from', None) and else_data:
+            else_data = re.sub('^\r\n', '', else_data)
+            else_data = re.sub('\r\n$', '', else_data)
 
-    if flask.request.args.get('from', None) and else_data:
-        else_data = re.sub('^\r\n', '', else_data)
-        else_data = re.sub('\r\n$', '', else_data)
+        end_data = render_set(
+            title = name,
+            data = else_data
+        )
 
-    end_data = render_set(
-        title = 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 end_data == 'HTTP Request 401.3':
         response_data = 401

+ 1 - 1
version.json

@@ -1,6 +1,6 @@
 {
     "master" : {
-        "r_ver" : "v3.1.6-master-19",
+        "r_ver" : "v3.1.6-master-20",
         "c_ver" : "400009",
         "s_ver" : "7"
     }, "stable" : {