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 unset_cache() to remove single keys from a cached_method #16505

Open
saraedum opened this issue Jun 20, 2014 · 21 comments
Open

Add unset_cache() to remove single keys from a cached_method #16505

saraedum opened this issue Jun 20, 2014 · 21 comments

Comments

@saraedum
Copy link
Member

A cached_method's clear_cache() clears the entire dictionary of a cached_method. Currently, there is no way to only remove some keys. This is sometimes necessary if values in the cache are not usable anymore (e.g. because they are defined in some external expect interface but the external session is not running anymore).

Component: misc

Keywords: cached_method

Author: Julian Rueth

Branch/Commit: u/saraedum/ticket/16505 @ 9cee22e

Issue created by migration from https://trac.sagemath.org/ticket/16505

@saraedum saraedum added this to the sage-6.3 milestone Jun 20, 2014
@saraedum

This comment has been minimized.

@saraedum saraedum changed the title Modify cached_method's clear_cache() to remove single keys Add unset_cache() to remove single keys from a cached_method Jun 20, 2014
@saraedum
Copy link
Member Author

Branch: u/saraedum/ticket/16505

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Jun 23, 2014

Commit: 7b01ec8

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Jun 23, 2014

Branch pushed to git repo; I updated commit sha1. New commits:

7b01ec8Merge branch 'develop' into ticket/16505

@saraedum

This comment has been minimized.

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Jul 23, 2014

Changed commit from 7b01ec8 to 91e09ce

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Jul 23, 2014

Branch pushed to git repo; I updated commit sha1. New commits:

91e09ceMerge branch 'develop' into ticket/16505

@sagetrac-vbraun-spam sagetrac-vbraun-spam mannequin modified the milestones: sage-6.3, sage-6.4 Aug 10, 2014
@nathanncohen
Copy link
Mannequin

nathanncohen mannequin commented Jan 10, 2015

comment:7

From the looks of the function set_cache just above the one that you define, it seems that you should also handle the case of non-hashable keys.

Nathann

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Dec 23, 2015

Branch pushed to git repo; I updated commit sha1. New commits:

01f8fceMerge branch 'develop' into t/16505/ticket/16505

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Dec 23, 2015

Changed commit from 91e09ce to 01f8fce

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Dec 23, 2015

Branch pushed to git repo; I updated commit sha1. New commits:

29d8e83handle unhashable keys in unset_cache

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Dec 23, 2015

Changed commit from 01f8fce to 29d8e83

@jdemeyer
Copy link

comment:10

Please rebase this on top of #19768.

@jdemeyer
Copy link

Dependencies: #19768

@jdemeyer
Copy link

Changed dependencies from #19768 to none

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Jan 9, 2016

Branch pushed to git repo; I updated commit sha1. New commits:

0bcb93fMerge branch 'develop' into t/16505/ticket/16505

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Jan 9, 2016

Changed commit from 29d8e83 to 0bcb93f

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Jan 9, 2016

Changed commit from 0bcb93f to 9cee22e

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Jan 9, 2016

Branch pushed to git repo; I updated commit sha1. New commits:

9cee22efix build error

@jdemeyer
Copy link

jdemeyer commented Jan 9, 2016

comment:15

Please use the get_key_args_kwds() and dict_key() functions added recently to cached functions.

@jdemeyer
Copy link

jdemeyer commented Jan 9, 2016

Replying to @saraedum:

Currently, there is no way to only remove some keys. This is sometimes necessary if values in the cache are not usable anymore

For this use case, I see no reason to raise KeyError when the key does not exist: I would just ignore non-existing keys.

You should add doctests showing that this also works for a weak cached function and a cached method (not just plain cached functions).

@jdemeyer jdemeyer modified the milestones: sage-6.4, sage-7.0 Jan 9, 2016
@mkoeppe mkoeppe removed this from the sage-7.0 milestone Dec 29, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants