-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
93b6d72
commit 4d3cfdd
Showing
4 changed files
with
98 additions
and
54 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,48 @@ | ||
<!-- This file is compiled from bolt-cache/bolt/cache/README.md. Do not edit this file directly. --> | ||
|
||
# bolt-cache | ||
# Cache | ||
|
||
Caching API with several different backends. | ||
A simple cache using the database. | ||
|
||
The Bolt Cache stores JSON-serializable values in a `CachedItem` model. | ||
Cached data can be set to expire after a certain amount of time. | ||
|
||
Access to the cache is provided through the `Cached` class. | ||
|
||
```python | ||
from bolt.cache import Cached | ||
|
||
|
||
cached = Cached("my-cache-key") | ||
|
||
if cached.exists(): | ||
print("Cache hit and not expired!") | ||
print(cached.value) | ||
else: | ||
print("Cache miss!") | ||
cached.set("a JSON-serializable value", expiration=60) | ||
|
||
# Delete the item if you need to | ||
cached.delete() | ||
``` | ||
|
||
Expired cache items can be cleared with `bolt cache clear-expired`. | ||
You can run this on a schedule through various cron-like tools or [bolt-worker](../../../bolt-worker/bolt/worker/). | ||
|
||
## Installation | ||
|
||
- install pkg | ||
- add to INSTALLED_APPS | ||
Add `bolt.cache` to your `INSTALLED_PACKAGES`: | ||
|
||
```python | ||
# app/settings.py | ||
INSTALLED_PACKAGES = [ | ||
# ... | ||
"bolt.cache", | ||
] | ||
``` | ||
|
||
## CLI | ||
|
||
- `bolt cache clear-expired` - Clear all expired cache items | ||
- `bolt cache clear-all` - Clear all cache items | ||
- `bolt cache stats` - Show cache statistics |
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 |
---|---|---|
@@ -1,10 +1,46 @@ | ||
# bolt-cache | ||
# Cache | ||
|
||
Caching API with several different backends. | ||
A simple cache using the database. | ||
|
||
The Bolt Cache stores JSON-serializable values in a `CachedItem` model. | ||
Cached data can be set to expire after a certain amount of time. | ||
|
||
Access to the cache is provided through the `Cached` class. | ||
|
||
```python | ||
from bolt.cache import Cached | ||
|
||
|
||
cached = Cached("my-cache-key") | ||
|
||
if cached.exists(): | ||
print("Cache hit and not expired!") | ||
print(cached.value) | ||
else: | ||
print("Cache miss!") | ||
cached.set("a JSON-serializable value", expiration=60) | ||
|
||
# Delete the item if you need to | ||
cached.delete() | ||
``` | ||
|
||
Expired cache items can be cleared with `bolt cache clear-expired`. | ||
You can run this on a schedule through various cron-like tools or [bolt-worker](../../../bolt-worker/bolt/worker/). | ||
|
||
## Installation | ||
|
||
- install pkg | ||
- add to INSTALLED_APPS | ||
Add `bolt.cache` to your `INSTALLED_PACKAGES`: | ||
|
||
```python | ||
# app/settings.py | ||
INSTALLED_PACKAGES = [ | ||
# ... | ||
"bolt.cache", | ||
] | ||
``` | ||
|
||
## CLI | ||
|
||
- `bolt cache clear-expired` - Clear all expired cache items | ||
- `bolt cache clear-all` - Clear all cache items | ||
- `bolt cache stats` - Show cache statistics |
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