-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add ability to clean & purge cache from pax
- Loading branch information
1 parent
4db99ed
commit 1ffd5df
Showing
4 changed files
with
62 additions
and
11 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import ../api/cfcache | ||
import ../term/log | ||
|
||
proc paxCache*(action: string): void = | ||
## clean/purge the cache | ||
case action: | ||
of "clean": | ||
echoInfo "Cleaning cache..." | ||
let numCleanedItems = cfcache.clean() | ||
echoInfo "Removed ", numCleanedItems.`$`.fgCyan, " items." | ||
of "purge": | ||
echoInfo "Purging cache..." | ||
cfcache.purge() | ||
echoInfo "Purged cache." | ||
else: | ||
discard |
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 |
---|---|---|
@@ -1,22 +1,24 @@ | ||
import std/[json, options, os] | ||
import std/[json, options] | ||
import api/cfcache | ||
|
||
block: # caching addons | ||
removeFile(getAddonFilename(123)) | ||
cfcache.purge() | ||
|
||
block: # caching addons | ||
let json = %* { | ||
"id": 123 | ||
} | ||
doAssert getAddon(123).isNone() | ||
putAddon(json) | ||
cfcache.putAddon(json) | ||
doAssert getAddon(123).get() == json | ||
|
||
block: # caching addons | ||
removeFile(getAddonFileFilename(456)) | ||
|
||
block: # caching addon files | ||
let json = %* { | ||
"id": 456 | ||
} | ||
doAssert getAddonFile(456).isNone() | ||
putAddonFile(json) | ||
doAssert getAddonFile(456).get() == json | ||
cfcache.putAddonFile(json) | ||
doAssert getAddonFile(456).get() == json | ||
|
||
block: # cleaning | ||
let numCleanedFiles = cfcache.clean() | ||
doAssert numCleanedFiles == 0 |