Skip to content

Support for surfacing cache status to caller #44

@mnutt

Description

@mnutt

I'm looking into using galaxycache to replace an existing API caching system. One of the things I was hoping to do was to log detailed caching info in my request logs. My origin API is particularly sensitive to duplicates so I field a lot of questions like "why did these two requests that came in so close together result in two cache misses" and it's useful to have request logs to debug.

I see that there is built-in tracing support, is there any way to extract a cache status from that? I'm imagining that from a Get() call, I'd like to know a) was the current node authoritative, and b) was the result a local_miss, peer_miss, peer_hit, maincache_hit, hotcache_hit etc. I think from looking through the source that we have most of this information through authoritative and hitLevel, the only one I don't see is how to distinguish between a peer hit or miss.

I'm not wedded to any implementation in particular, but was imagining maybe something like this?

type Metadata struct {
	Level              hitLevel
	LocalAuthoritative bool
	PeerErr            error
	LocalErr           error
}

func (g *Galaxy) GetWithMetadata(ctx context.Context, key string, dest Codec) (*Metadata, error) { }

I opened this issue to make sure that I wasn't missing an obvious way to handle this, and to see if adding it would be something that would be in line with the project's goals. Thanks!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions