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

How to disable caching on default table? #278

Closed
bengineer19 opened this issue Aug 16, 2019 · 5 comments

Comments

@bengineer19
Copy link

@bengineer19 bengineer19 commented Aug 16, 2019

Hi!

Firstly, thanks for making an awesome project.
From the docs, I can see that it's possible to disable caching on a particular table using cache_size=0 in the constructor of db.table().

But what if I'm using the default table? Is it possible to disable query caching?

Thanks!

@msiemens

This comment has been minimized.

Copy link
Owner

@msiemens msiemens commented Aug 21, 2019

Hey @bengineer19,

That's an interesting question! Seems like right now there is no way to disable caching on the default table using the public API.

A quick workaround would be to set db._table._query_cache.capacity = 0. But that's not a really clean solution. I gues we could add an attribute like TinyDB.DEFAULT_TABLE_KWARGS which can specify arguments to the Table class like this:

TinyDB.DEFAULT_TABLE_KWARGS = {'cache_size': 0}

What do you think?

@bengineer19

This comment has been minimized.

Copy link
Author

@bengineer19 bengineer19 commented Aug 21, 2019

Yep I think that seems reasonable.
It's definitely an edge case, so as long as there's some way to "forward" parameters from TinyDB() to self._table = self.table(default_table) I think it should work.

msiemens added a commit that referenced this issue Aug 21, 2019
Closes #278
@msiemens

This comment has been minimized.

Copy link
Owner

@msiemens msiemens commented Aug 21, 2019

I've created a pull request at #279, I'll need to think about what the best API is for this feature 🙃

@msiemens msiemens added the pinned label Sep 12, 2019
msiemens added a commit that referenced this issue Sep 13, 2019
Closes #278
@msiemens msiemens closed this in 480b172 Oct 12, 2019
@msiemens

This comment has been minimized.

Copy link
Owner

@msiemens msiemens commented Oct 12, 2019

I've now published this feature in the new TinyDB v3.15.0 🙃

@bengineer19

This comment has been minimized.

Copy link
Author

@bengineer19 bengineer19 commented Oct 12, 2019

Awesome - thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants
You can’t perform that action at this time.