@ndb.tasklet<EOL>def memoizing_fibonacci(n):
if n <= <NUM_LIT:1>:<EOL><INDENT>raise ndb.Return(n)<EOL><DEDENT>key = ndb.Key(FibonacciMemo, str(n))<EOL>memo = yield key.get_async(ndb_should_cache=False)<EOL>if memo is not None:<EOL><INDENT>assert memo.arg == n<EOL>logging.info('<STR_LIT>', n, memo.value)<EOL>raise ndb.Return(memo.value)<EOL><DEDENT>logging.info('<STR_LIT>', n)<EOL>a = yield memoizing_fibonacci(n - <NUM_LIT:1>)<EOL>b = yield memoizing_fibonacci(n - <NUM_LIT:2>)<EOL>ans = a + b<EOL>memo = FibonacciMemo(key=key, arg=n, value=ans)<EOL>logging.info('<STR_LIT>', n, memo.value)<EOL>yield memo.put_async(ndb_should_cache=False)<EOL>raise ndb.Return(ans)<EOL>
A memoizing recursive Fibonacci to exercise RPCs.