Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type AppendOnly ¶
AppendOnly is a thread-safe cache that allows appending new items.
func NewAppendCache ¶
NewAppendCache creates a new APODCache
func (*AppendOnly[T]) Add ¶
func (c *AppendOnly[T]) Add(date string, response T) error
Add a single day to the cache
func (*AppendOnly[T]) Get ¶
func (c *AppendOnly[T]) Get(date string) (T, bool)
Get a single day from the cache
func (*AppendOnly[T]) Has ¶
func (c *AppendOnly[T]) Has(date string) bool
Has checks if a day is present in the cache
type Empty ¶
type Empty[T any] struct{}
Empty cache that does nothing
type FS ¶
type FS interface { HasFile(name string) bool WriteFile(name string, data []byte) error ReadFile(name string) ([]byte, error) }
FS is an interface that abstracts over types that behave like a file system. This includes both a local file system and a mock in-memory file system.
type FSCache ¶
type FSCache[T any] struct { // contains filtered or unexported fields }
FSCache is a cache that stores cached items in a "file system".
func NewFSCache ¶
func NewFSCache[T any]( fs FS, serializer func([]byte) (T, error), deserializer func(T) ([]byte, error), ) *FSCache[T]
NewFSCache creates a new FSCache.
type HasDate ¶
type HasDate interface {
GetDate() string
}
HasDate is an interface for types that have a date based timestamp
type InMemoryFS ¶
type InMemoryFS struct {
// contains filtered or unexported fields
}
InMemoryFS is a file system that stores files in memory.
func (*InMemoryFS) HasFile ¶
func (fs *InMemoryFS) HasFile(name string) bool
HasFile checks if a file exists.
Click to show internal directories.
Click to hide internal directories.