Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement clientside caching with Tiled #133

Open
hannahker opened this issue Oct 3, 2023 · 2 comments
Open

Implement clientside caching with Tiled #133

hannahker opened this issue Oct 3, 2023 · 2 comments
Assignees
Labels
enhancement New feature or request

Comments

@hannahker
Copy link
Collaborator

hannahker commented Oct 3, 2023

Performance improvement.

@hannahker hannahker changed the title Placeholder: Implement clientside cahing with Tiled? Implement clientside caching with Tiled Oct 3, 2023
@Wiebke
Copy link
Member

Wiebke commented Oct 3, 2023

I don't have time to create a PR for this right now, but sharing the pieces that I have added:
in data_utils.py:

In the section of module imports, add:

from tiled.client.cache import Cache
from tiled.client import show_logs

In the else statement to reach a remote Tiled server, add:

cache = Cache(
        capacity=500_000_000,  # bytes
        max_item_size=500_000,  # bytes
        filepath="data/tiled_cache.db",
        readonly=False,
    )

Add the cache to the client initaliztation:

client = from_uri(TILED_URI, api_key=API_KEY, cache=cache, timeout=httpx.Timeout(60.0))

To additionally show statistics on caching and timing of server requests etc, add:

# Show Tiled logs
if os.getenv("TILED_LOGS", False):
    show_logs()

@hannahker
Copy link
Collaborator Author

Note: How can we configure the timeout?

@hannahker hannahker added the enhancement New feature or request label Oct 6, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants