Skip to content

Commit

Permalink
temporarily enable ndb context cache for everything
Browse files Browse the repository at this point in the history
for #1149
  • Loading branch information
snarfed committed Jan 12, 2025
1 parent 2437a16 commit 18aa302
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
12 changes: 7 additions & 5 deletions common.py
Original file line number Diff line number Diff line change
Expand Up @@ -390,12 +390,14 @@ def cache_policy(key):
Returns:
bool: whether to cache this object
"""
if isinstance(key, Key):
# use internal google.cloud.datastore.key.Key
# https://github.com/googleapis/python-ndb/issues/987
key = key._key
return True

# if isinstance(key, Key):
# # use internal google.cloud.datastore.key.Key
# # https://github.com/googleapis/python-ndb/issues/987
# key = key._key

return key and key.kind == 'Object' and key.name.startswith('did:')
# return key and key.kind == 'Object' and key.name.startswith('did:')


def global_cache_policy(key):
Expand Down
2 changes: 2 additions & 0 deletions tests/test_common.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Unit tests for common.py."""
from unittest import skip
from unittest.mock import Mock, patch

import flask
Expand Down Expand Up @@ -112,6 +113,7 @@ def test_host_url(self):
with app.test_request_context(base_url='https://bsky.brid.gy', path='/foo'):
self.assertEqual('https://bsky.brid.gy/asdf', common.host_url('asdf'))

@skip
def test_cache_policy(self):
for id in 'did:plc:foo', 'did:web:foo':
self.assertTrue(common.cache_policy(Object(id=id).key))
Expand Down

0 comments on commit 18aa302

Please sign in to comment.