mirror of
https://git.anonymousland.org/anonymousland/synapse.git
synced 2025-05-02 11:06:07 -04:00
Allow @cached-wrapped functions to have a prefill method for setting entries
This commit is contained in:
parent
4631b737fd
commit
e76d485e29
2 changed files with 29 additions and 8 deletions
|
@ -87,3 +87,17 @@ class CacheDecoratorTestCase(unittest.TestCase):
|
|||
|
||||
self.assertTrue(callcount[0] >= 14,
|
||||
msg="Expected callcount >= 14, got %d" % (callcount[0]))
|
||||
|
||||
@defer.inlineCallbacks
|
||||
def test_prefill(self):
|
||||
callcount = [0]
|
||||
|
||||
@cached()
|
||||
def func(self, key):
|
||||
callcount[0] += 1
|
||||
return key
|
||||
|
||||
func.prefill("foo", 123)
|
||||
|
||||
self.assertEquals((yield func(self, "foo")), 123)
|
||||
self.assertEquals(callcount[0], 0)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue