mirror of
https://github.com/stashapp/stash.git
synced 2025-12-17 13:56:27 +01:00
* Add gql client generation files * Update dependencies * Add stash-box client generation to the makefile * Move scraped scene object matchers to models * Add stash-box to scrape with dropdown * Add scrape scene from fingerprint in UI
29 lines
983 B
Go
29 lines
983 B
Go
package graphql
|
|
|
|
import "context"
|
|
|
|
// Cache is a shared store for APQ and query AST caching
|
|
type Cache interface {
|
|
// Get looks up a key's value from the cache.
|
|
Get(ctx context.Context, key string) (value interface{}, ok bool)
|
|
|
|
// Add adds a value to the cache.
|
|
Add(ctx context.Context, key string, value interface{})
|
|
}
|
|
|
|
// MapCache is the simplest implementation of a cache, because it can not evict it should only be used in tests
|
|
type MapCache map[string]interface{}
|
|
|
|
// Get looks up a key's value from the cache.
|
|
func (m MapCache) Get(ctx context.Context, key string) (value interface{}, ok bool) {
|
|
v, ok := m[key]
|
|
return v, ok
|
|
}
|
|
|
|
// Add adds a value to the cache.
|
|
func (m MapCache) Add(ctx context.Context, key string, value interface{}) { m[key] = value }
|
|
|
|
type NoCache struct{}
|
|
|
|
func (n NoCache) Get(ctx context.Context, key string) (value interface{}, ok bool) { return nil, false }
|
|
func (n NoCache) Add(ctx context.Context, key string, value interface{}) {}
|