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

Add CACHALOT_ONLY_CACHABLE_APPS & CACHALOT_UNCACHABLE_APPS (Fixes #186) #187

Merged
merged 1 commit into from
May 25, 2021

Conversation

Andrew-Chen-Wang
Copy link
Collaborator

Description

Fixes #186

Rationale

Makes adding an entire app more convenient.

Caveat: someone like Reddit has a table like "subreddit_23k2d" as in the last 5 letters give an identification number. This is... not very Django like thus it does not satisfy the wildcard notation that was initially mentioned in the issue. Someone else can monkey patch the functions from

def is_cachable(table):
whitelist = cachalot_settings.CACHALOT_ONLY_CACHABLE_TABLES
if whitelist and table not in whitelist:
return False
return table not in cachalot_settings.CACHALOT_UNCACHABLE_TABLES
def are_all_cachable(tables):
whitelist = cachalot_settings.CACHALOT_ONLY_CACHABLE_TABLES
if whitelist and not tables.issubset(whitelist):
return False
return tables.isdisjoint(cachalot_settings.CACHALOT_UNCACHABLE_TABLES)
def filter_cachable(tables):
whitelist = cachalot_settings.CACHALOT_ONLY_CACHABLE_TABLES
tables = tables.difference(cachalot_settings.CACHALOT_UNCACHABLE_TABLES)
if whitelist:
return tables.intersection(whitelist)
return tables
to include any sort of wildcard functionality. The reason I didn't implement a wildcard functionality is due to performance reasons. Though, that could change if I can make a benchmark (or someone else) that convinces me that a Pythonic solution is alright performance wise.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Allow wildcards in CACHALOT_UNCACHABLE_TABLES
1 participant