Implementation:1broseidon Ketch cache RemoveTag RemoveTagged
| Knowledge Sources | |
|---|---|
| Domains | Caching, Tagging |
| Last Updated | 2026-10-27 00:00 GMT |
Overview
Deletes from the durable tag index: `RemoveTag` drops a whole tag; `RemoveTagged` drops specific URLs and reports which were not found.
Description
RemoveTag deletes every entry under a tag (and the source-bucket index entries) and returns the count removed. RemoveTagged takes a tag and a list of URL keys, drops only those entries, and returns the count removed plus the URLs not found under the tag. Both open their bbolt file only for the transaction (ADR-0006).
Usage
Backs `ketch tag remove <tag> [url...]` (no URLs drops the whole tag; with URLs, drops only those) and the MCP `tag` tool's remove operation. The CLI exits 3 when nothing was removed.
Code Reference
Source Location
- Repository: ketch
- File: cache/tags.go, cache/tag_store.go
Signature
// RemoveTag drops the whole tag; returns the count removed.
func (c *Cache) RemoveTag(tag string) (int, error)
// RemoveTagged drops specific URLs from a tag; returns count + not-found URLs.
func (c *Cache) RemoveTagged(tag string, keys []string) (removed int, missing []string, err error)
Import
import "github.com/1broseidon/ketch/cache"
I/O Contract
Inputs (RemoveTagged)
| Name | Type | Required | Description |
|---|---|---|---|
| tag | string | Yes | Validated tag name |
| keys | []string | Yes | Cache keys of the URLs to drop |
Outputs (RemoveTagged)
| Name | Type | Description |
|---|---|---|
| removed | int | Count of entries actually removed |
| missing | []string | Keys not found under the tag |
| err | error | Validation / bbolt failure |
Usage Examples
Drop a Whole Tag
removed, err := tags.RemoveTag("docs")
if removed == 0 { /* CLI exits 3: nothing to remove */ }
Drop Specific URLs
removed, missing, err := tags.RemoveTagged("docs", []string{key1, key2})
for _, m := range missing {
fmt.Fprintf(os.Stderr, "warn: %s not under tag docs\n", m)
}