mirror of
				https://github.com/TitanEmbeds/Titan.git
				synced 2025-11-03 23:37:09 +01:00 
			
		
		
		
	Change the cache key abit and extended cache time
This commit is contained in:
		@@ -3,7 +3,7 @@ import json
 | 
			
		||||
from requests_oauthlib import OAuth2Session
 | 
			
		||||
from flask import session, abort, url_for
 | 
			
		||||
from titanembeds.database import get_keyvalproperty, set_keyvalproperty
 | 
			
		||||
from titanembeds.utils import make_cache_key
 | 
			
		||||
from titanembeds.utils import make_user_cache_key
 | 
			
		||||
 | 
			
		||||
authorize_url = "https://discordapp.com/api/oauth2/authorize"
 | 
			
		||||
token_url = "https://discordapp.com/api/oauth2/token"
 | 
			
		||||
@@ -52,7 +52,7 @@ def get_user_guilds():
 | 
			
		||||
    if req.status_code != 200:
 | 
			
		||||
        abort(req.status_code)
 | 
			
		||||
    req = json.dumps(req.json())
 | 
			
		||||
    set_keyvalproperty("OAUTH/USERGUILDS/"+make_cache_key(), req, 100)
 | 
			
		||||
    set_keyvalproperty("OAUTH/USERGUILDS/"+make_user_cache_key(), req, 250)
 | 
			
		||||
    return req
 | 
			
		||||
 | 
			
		||||
def get_user_managed_servers():
 | 
			
		||||
 
 | 
			
		||||
@@ -32,6 +32,11 @@ def make_cache_key(*args, **kwargs):
 | 
			
		||||
    sess = generate_session_key()
 | 
			
		||||
    return (path + args + sess + ip).encode('utf-8')
 | 
			
		||||
 | 
			
		||||
def make_user_cache_key(*args, **kwargs)
 | 
			
		||||
    ip = get_client_ipaddr()
 | 
			
		||||
    sess = generate_session_key()
 | 
			
		||||
    return (sess + ip).encode('utf-8')
 | 
			
		||||
 | 
			
		||||
def make_guilds_cache_key():
 | 
			
		||||
    sess = generate_session_key()
 | 
			
		||||
    ip = get_client_ipaddr()
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user