mirror of
https://github.com/reddit-archive/reddit.git
synced 2026-01-27 07:48:16 -05:00
Add a memoized method of get_count, and use it by default.
This commit is contained in:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user