make cache keys unique with djangobb_ prefix

This commit is contained in:
slav0nic 2012-04-26 14:27:49 +03:00
parent a9ddfd239c
commit 4ffde71697
3 changed files with 8 additions and 8 deletions

View file

@ -9,7 +9,7 @@ from djangobb_forum import settings as forum_settings
class LastLoginMiddleware(object):
def process_request(self, request):
if request.user.is_authenticated():
cache.set(str(request.user.id), True, forum_settings.USER_ONLINE_TIMEOUT)
cache.set('djangobb_user%d' % request.user.id, True, forum_settings.USER_ONLINE_TIMEOUT)
class ForumMiddleware(object):
def process_request(self, request):
@ -30,8 +30,8 @@ class UsersOnline(object):
def process_request(self, request):
now = datetime.now()
delta = now - timedelta(minutes=forum_settings.USER_ONLINE_TIMEOUT)
users_online = cache.get('users_online', {})
guests_online = cache.get('guests_online', {})
users_online = cache.get('djangobb_users_online', {})
guests_online = cache.get('djangobb_guests_online', {})
if request.user.is_authenticated():
users_online[request.user.id] = now
@ -47,5 +47,5 @@ class UsersOnline(object):
if guests_online[guest_id] < delta:
del guests_online[guest_id]
cache.set('users_online', users_online, 60*60*24)
cache.set('guests_online', guests_online, 60*60*24)
cache.set('djangobb_users_online', users_online, 60*60*24)
cache.set('djangobb_guests_online', guests_online, 60*60*24)

View file

@ -228,7 +228,7 @@ def forum_authority(user):
@register.filter
def online(user):
return cache.get(str(user.id))
return cache.get('djangobb_user%d' % user.id)
@register.filter
def attachment_link(attach):

View file

@ -29,9 +29,9 @@ from haystack.query import SearchQuerySet, SQ
def index(request, full=True):
users_cached = cache.get('users_online', {})
users_cached = cache.get('djangobb_users_online', {})
users_online = users_cached and User.objects.filter(id__in = users_cached.keys()) or []
guests_cached = cache.get('guests_online', {})
guests_cached = cache.get('djangobb_guests_online', {})
guest_count = len(guests_cached)
users_count = len(users_online)