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

Cache management #40

Open
sjkisner opened this issue Nov 3, 2020 · 9 comments
Open

Cache management #40

sjkisner opened this issue Nov 3, 2020 · 9 comments

Comments

@sjkisner
Copy link
Collaborator

sjkisner commented Nov 3, 2020

Add functions to "list" and "clear" sysmatrix files from cache directory.

We should use "touch" or something equivalent to update the time stamp of the sysmatrix file each time it's accessed in order to assigning priority.

@smajee
Copy link
Collaborator

smajee commented Nov 4, 2020

So, every-time we run recon or project, we should 'touch' the sysmatrix file?

@cabouman
Copy link
Owner

cabouman commented Nov 4, 2020

Yes, that way its time stamp will update.

@sjkisner
Copy link
Collaborator Author

sjkisner commented Nov 4, 2020

We can just do it in one place, under the line that prints "Found system matrix".

Not sure "touch" will work in Windows though unless it's run in a bash emulator.

@bwohlberg
Copy link
Collaborator

There's a useful discussion here on how to implement touch in an OS-independent fashion.

@sjkisner
Copy link
Collaborator Author

sjkisner commented Nov 4, 2020

Yes! This works for me on Linux,Mac,Windows:
import os
os.utime(sysmatrix_name+'.2Dsvmatrix')

The above is all we need here because we just need to update the modified time for a file that exists.

@cabouman
Copy link
Owner

cabouman commented Nov 6, 2020

OK, we have added a touch command that updates the last modification time for the library files.

After some thought, maybe it would be best to create a separate utility svmbir.clean_lib(N) that would clean out the library and only retain the N most recent files.

Do people like this idea?

@sjkisner
Copy link
Collaborator Author

sjkisner commented Nov 6, 2020

Sounds good. There's already a function _clear_cache() that could be modified.

I'd suggest having it default to cleaning the cache folder entirely. Like
clear_cache(svmbir_lib_path=None, num_sysmatrix=0)
where num_sysmatrix is number of most recent matrix files.

We should take care to identify the specified path as a valid cache folder so it can't be used to obliterate an arbitrary folder.

@cabouman
Copy link
Owner

cabouman commented Dec 3, 2020

We should implement a function clear_cache() that first prompts the user with something like:

Would you like to delete your cache directory? [y/n]

Then if the user responds with a y, it calls _clear_cache().

@cabouman
Copy link
Owner

Brendts suggestion: Perhaps allow the user to specify a maximum cache size? If writing a
new file exceeds it, automatically delete the oldest files until it's
under the threshold?

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

No branches or pull requests

4 participants