Add a memoized method of get_count, and use it by default.

This commit is contained in:
Jason Harvey
2012-08-16 19:21:40 -07:00
parent 1fa2d40f27
commit 49607b72d1

View File

@@ -820,5 +820,10 @@ class AccountsActiveBySR(tdb_cassandra.View):
{account._id36: ''})
@classmethod
def get_count(cls, sr):
return cls._cf.get_count(sr._id36)
def get_count(cls, sr, cached=True):
return cls.get_count_cached(sr._id36, _update=not cached)
@classmethod
@memoize('accounts_active', time=60)
def get_count_cached(cls, sr_id):
return cls._cf.get_count(sr_id)