-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Simplify the cache module and interface (#20)
- Supports tags - Fixed issues with sqlalchemy and session handling - Supports various compression methods in the hashlib library - Cleanup expired resources in the cache - Updated documentation & tests
- Loading branch information
Showing
15 changed files
with
963 additions
and
489 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
# Best Practices | ||
|
||
1. Use context managers for cleanup: | ||
```python | ||
with BiocFileCache("cache_directory") as cache: | ||
cache.add("myfile", "path/to/file.txt") | ||
``` | ||
|
||
2. Add tags for better organization: | ||
```python | ||
cache.add("data.csv", "data.csv", tags=["raw", "csv", "2024"]) | ||
``` | ||
|
||
3. Set expiration dates for temporary files: | ||
```python | ||
cache.add("temp.txt", "temp.txt", expires=datetime.now() + timedelta(hours=1)) | ||
``` | ||
|
||
4. Regular maintenance: | ||
```python | ||
# Periodically clean up expired resources | ||
cache.cleanup() | ||
|
||
# Monitor cache size | ||
stats = cache.get_stats() | ||
if stats["cache_size_bytes"] > threshold: | ||
# Take action | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.