From d29d70565d4150b8b37443c2cc7770ec57c93efb Mon Sep 17 00:00:00 2001 From: Jeremy Zhang Date: Mon, 8 May 2017 21:44:05 -0700 Subject: [PATCH] Change the cache key abit and extended cache time --- webapp/titanembeds/oauth.py | 4 ++-- webapp/titanembeds/utils.py | 5 +++++ 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/webapp/titanembeds/oauth.py b/webapp/titanembeds/oauth.py index 4c793fe..569e2ed 100644 --- a/webapp/titanembeds/oauth.py +++ b/webapp/titanembeds/oauth.py @@ -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(): diff --git a/webapp/titanembeds/utils.py b/webapp/titanembeds/utils.py index 6e716cd..d54d98f 100644 --- a/webapp/titanembeds/utils.py +++ b/webapp/titanembeds/utils.py @@ -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()