I give up caching

This commit is contained in:
Jeremy Zhang 2017-04-22 02:30:02 -07:00
parent e4737444bd
commit 185bf27149
2 changed files with 2 additions and 2 deletions

View File

@ -1,6 +1,6 @@
from titanembeds.database import db, Guilds, UnauthenticatedUsers, UnauthenticatedBans, AuthenticatedUsers from titanembeds.database import db, Guilds, UnauthenticatedUsers, UnauthenticatedBans, AuthenticatedUsers
from titanembeds.decorators import valid_session_required, discord_users_only from titanembeds.decorators import valid_session_required, discord_users_only
from titanembeds.utils import check_guild_existance, guild_query_unauth_users_bool, get_client_ipaddr, discord_api, rate_limiter, channel_ratelimit_key, guild_ratelimit_key, cache, make_guildchannels_cache_key from titanembeds.utils import check_guild_existance, guild_query_unauth_users_bool, get_client_ipaddr, discord_api, rate_limiter, channel_ratelimit_key, guild_ratelimit_key
from titanembeds.oauth import user_has_permission, generate_avatar_url, check_user_can_administrate_guild from titanembeds.oauth import user_has_permission, generate_avatar_url, check_user_can_administrate_guild
from flask import Blueprint, abort, jsonify, session, request from flask import Blueprint, abort, jsonify, session, request
from sqlalchemy import and_ from sqlalchemy import and_
@ -114,7 +114,6 @@ def format_post_content(message):
message = "**<{}#{}>** {}".format(session['username'], session['discriminator'], message) # I would like to do a @ mention, but i am worried about notif spam message = "**<{}#{}>** {}".format(session['username'], session['discriminator'], message) # I would like to do a @ mention, but i am worried about notif spam
return message return message
@cache.cache(make_guildchannels_cache_key, expire=60)
def get_guild_channels(guild_id): def get_guild_channels(guild_id):
if user_unauthenticated(): if user_unauthenticated():
member_roles = [guild_id] #equivilant to @everyone role member_roles = [guild_id] #equivilant to @everyone role

View File

@ -110,6 +110,7 @@ class DiscordREST:
r = self.request("GET", _endpoint) r = self.request("GET", _endpoint)
return r return r
@cache.cache('get_guild_channels', expire=200)
def get_guild_channels(self, guild_id): def get_guild_channels(self, guild_id):
_endpoint = "/guilds/{guild_id}/channels".format(guild_id=guild_id) _endpoint = "/guilds/{guild_id}/channels".format(guild_id=guild_id)
r = self.request("GET", _endpoint) r = self.request("GET", _endpoint)