# Understanding the Artifact Key Format in Dewy's Cache

> Discover Dewy's artifact key format. Learn how `<tag>--<artifact_name>` uniquely identifies cached artifacts using release tags and filenames for efficient retrieval.

- Repository: [Tomohisa Oda/dewy](https://github.com/linyows/dewy)
- Tags: internals
- Published: 2026-03-06

---

**Dewy uses a cache key format of `<tag>--<artifact_name>` to uniquely identify stored artifacts, combining the release version tag with the base filename using a double hyphen separator.**

The `linyows/dewy` repository implements a deterministic caching mechanism to avoid redundant network requests when downloading release artifacts. Understanding the artifact key format in Dewy's cache is essential for debugging cache hits, configuring storage backends, or extending the tool's functionality.

## What Is the Artifact Key Format in Dewy?

Dewy generates cache keys using a strict two-part format:

```

<tag>--<artifact_name>

```

- **`<tag>`**: The version tag reported by the registry (e.g., `v1.2.3`, `v2.0.0-rc.1`)
- **`<artifact_name>`**: The base filename of the artifact (e.g., `app_linux_amd64.tar.gz`, `dewy_darwin_arm64.zip`)

The double hyphen (`--`) serves as an unambiguous delimiter that prevents collisions between version strings and filenames.

## How Dewy Generates Cache Keys

### The cachekeyName Implementation

The core logic resides in [`dewy.go`](https://github.com/linyows/dewy/blob/main/dewy.go) within the `cachekeyName` helper function. According to the source code at lines 241-244, Dewy constructs the key using `fmt.Sprintf`:

```go
func (d *Dewy) cachekeyName(res *registry.CurrentResponse) string {
    // u[0] represents the artifact URL from the response
    return fmt.Sprintf("%s--%s", res.Tag, filepath.Base(u[0]))
}

```

The `filepath.Base()` function extracts the filename from the full URL path, ensuring that query parameters or directory structures do not pollute the cache key.

### Key Generation Example

When Dewy processes a release tagged `v1.2.3` containing an artifact at `https://example.com/downloads/app_linux_amd64.tar.gz`, the generated cache key becomes:

```go
resTag := "v1.2.3"
artifactURL := "https://example.com/downloads/app_linux_amd64.tar.gz"

cacheKey := fmt.Sprintf("%s--%s", resTag, filepath.Base(artifactURL))
// Output: v1.2.3--app_linux_amd64.tar.gz

```

## Where the Format Is Documented and Tested

Dewy maintains consistency between implementation and documentation. The user-facing documentation in [`docs/pages/cache-configuration.md`](https://github.com/linyows/dewy/blob/main/docs/pages/cache-configuration.md) explicitly states that "Each artifact is assigned a unique key in the format `tag--artifact`".

The test suite in [`dewy_test.go`](https://github.com/linyows/dewy/blob/main/dewy_test.go) validates this behavior with concrete assertions. Tests verify that the `cachekeyName` function produces expected strings such as `"v1.0.0--artifact.zip"` when provided with specific registry responses.

## Summary

- Dewy's artifact cache keys follow the strict format `<tag>--<artifact_name>` using a double hyphen separator.
- The `cachekeyName` function in [`dewy.go`](https://github.com/linyows/dewy/blob/main/dewy.go) (lines 241-244) implements this logic using `fmt.Sprintf` and `filepath.Base`.
- The format is documented in [`docs/pages/cache-configuration.md`](https://github.com/linyows/dewy/blob/main/docs/pages/cache-configuration.md) and enforced by tests in [`dewy_test.go`](https://github.com/linyows/dewy/blob/main/dewy_test.go).
- Understanding this format helps debug cache issues and predict storage paths for downloaded artifacts.

## Frequently Asked Questions

### What separator does Dewy use in artifact cache keys?

Dewy uses a double hyphen (`--`) as the separator between the version tag and the artifact filename. This delimiter appears in the format `<tag>--<artifact_name>` and is hardcoded in the `cachekeyName` function within [`dewy.go`](https://github.com/linyows/dewy/blob/main/dewy.go).

### How does Dewy handle the artifact filename in the cache key?

Dewy extracts only the base filename from the full artifact URL using Go's `filepath.Base()` function. This ensures that directory paths, domain names, and query parameters are stripped away, leaving only the actual filename (e.g., `app_linux_amd64.tar.gz`) to be combined with the version tag.

### Where is the cache key generation logic located in Dewy?

The cache key generation logic resides in the `cachekeyName` method in [`dewy.go`](https://github.com/linyows/dewy/blob/main/dewy.go) at lines 241-244. This helper function accepts a `registry.CurrentResponse` object and returns a formatted string combining the release tag and the base artifact filename.

### Does Dewy include the full URL in the artifact cache key?

No, Dewy does not include the full URL in the cache key. The implementation specifically uses `filepath.Base(u[0])` to extract only the filename portion from the URL path. This design prevents cache invalidation issues caused by changing domain names or URL parameters while maintaining unique identification through the tag and filename combination.