Skip to content

Commit

Permalink
Merge pull request #100 from HathorNetwork/dev
Browse files Browse the repository at this point in the history
Release v0.1.11
  • Loading branch information
r4mmer authored Oct 15, 2021
2 parents e4c77e7 + 20fc430 commit 2a3457e
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 8 deletions.
6 changes: 4 additions & 2 deletions gateways/clients/cache_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,10 @@ def keys(self, collection: str) -> List[str]:
:return: the list of keys
:rtype: List[str]
"""
return [self._extract_key_from_context(key.decode()) for key in self.client.keys()
if key.decode().startswith(self._get_context_collection(collection))]
return [
self._extract_key_from_context(key.decode())
for key in self.client.scan_iter(self._get_context_collection(collection)+'.*')
]

def _extract_key_from_context(self, key: str) -> str:
"""Returns the simple key from a raw key. This is the reverse operation of `_get_context_key`
Expand Down
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "hathor-explorer-service",
"version": "0.1.10",
"version": "0.1.11",
"description": "Hathor Explorer Service Serverless deps",
"dependencies": {
"serverless": "^2.44.0",
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "hathor-explorer-service"
version = "0.1.10"
version = "0.1.11"
description = ""
authors = ["Hathor Labs <[email protected]>"]
license = "MIT"
Expand Down
11 changes: 8 additions & 3 deletions tests/unit/gateways/clients/test_cache_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,20 @@ def test_get(self, cache_client):
assert cache_client.get('lightsaber', 'purple') is None

def test_keys(self, cache_client):
cache_client.set('planet', 'tatooine', {'where': 'Middle of nowhere'})
cache_client.set('planet-system', 'kamino', {'where': 'Not in archives'})

cache_client.set('spaceships', 'millenium-falcon', {'owner': 'Han Solo'})
cache_client.set('spaceships', 'deathstar', {'owner': 'Darth Vader'})
cache_client.set('spaceships', 'x-wing', {'owner': 'Alliance'})
cache_client.set('darth-vader-children', 'luke', {'surname': 'skywalker'})
cache_client.set('darth-vader-children', 'leia', {'surname': 'organa'})

expected_planet_keys = ['tatooine']
expected_spaceships_keys = ['millenium-falcon', 'deathstar', 'x-wing']
expected_vader_chidren_keys = ['luke', 'leia']

assert cache_client.keys('spaceships') == expected_spaceships_keys
assert cache_client.keys('darth-vader-children') == expected_vader_chidren_keys
assert cache_client.keys('crash-sound') == []
assert sorted(cache_client.keys('planet')) == sorted(expected_planet_keys)
assert sorted(cache_client.keys('spaceships')) == sorted(expected_spaceships_keys)
assert sorted(cache_client.keys('darth-vader-children')) == sorted(expected_vader_chidren_keys)
assert sorted(cache_client.keys('crash-sound')) == []

0 comments on commit 2a3457e

Please sign in to comment.