Cache the results of Recipient queries in our memcached cache.

(imported from commit a6ba25a9c62d2738e4738b076370e4b2bc0ffaba)
This commit is contained in:
Tim Abbott
2013-03-18 11:54:58 -04:00
parent 3c143db01a
commit a23f6be28d
3 changed files with 20 additions and 20 deletions

View File

@@ -192,6 +192,10 @@ def get_stream(stream_name, realm):
except Stream.DoesNotExist:
return None
@cache_with_key(lambda type, type_id: "get_recipient:%s:%s" % (type, type_id,))
def get_recipient(type, type_id):
return Recipient.objects.get(type_id=type_id, type=type)
# NB: This function is currently unused, but may come in handy.
def linebreak(string):
return string.replace('\n\n', '<p/>').replace('\n', '<br/>')