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

Allow to clear the cache before anything is cached #5981

Merged
merged 1 commit into from
Dec 4, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions panel/io/cache.py
Original file line number Diff line number Diff line change
Expand Up @@ -433,6 +433,9 @@ def wrapped_func(*args, **kwargs):

def clear(session_context=None):
global func_hash
# clear called before anything is cached.
if 'func_hash' not in globals():
return
if func_hash is None:
return
if to_disk:
Expand Down
7 changes: 7 additions & 0 deletions panel/tests/io/test_cache.py
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,13 @@ def test_cache_clear():
fn.clear()
assert fn(0, 0) == 1

def test_cache_clear_before_cached():
# https://github.com/holoviz/panel/issues/5968
global OFFSET
OFFSET.clear()
fn = cache(function_with_args)
fn.clear()

def test_per_session_cache(document):
global OFFSET
OFFSET.clear()
Expand Down
Loading