Documentation
¶
Index ¶
- Variables
- type Cache
- func (c *Cache) AddLRUCronJob(ctx context.Context, schedule cron.Schedule)
- func (c *Cache) AddUpstreamCaches(ctx context.Context, ucs ...upstream.Cache)
- func (c *Cache) DeleteNar(ctx context.Context, narURL nar.URL) error
- func (c *Cache) DeleteNarInfo(ctx context.Context, hash string) error
- func (c *Cache) GetHostname() string
- func (c *Cache) GetNar(ctx context.Context, narURL nar.URL) (int64, io.ReadCloser, error)
- func (c *Cache) GetNarInfo(ctx context.Context, hash string) (*narinfo.NarInfo, error)
- func (c *Cache) PublicKey() signature.PublicKey
- func (c *Cache) PutNar(ctx context.Context, narURL nar.URL, r io.ReadCloser) error
- func (c *Cache) PutNarInfo(ctx context.Context, hash string, r io.ReadCloser) error
- func (c *Cache) SetCacheSignNarinfo(shouldSignNarinfo bool)
- func (c *Cache) SetMaxSize(maxSize uint64)
- func (c *Cache) SetRecordAgeIgnoreTouch(d time.Duration)
- func (c *Cache) SetupCron(ctx context.Context, timezone *time.Location)
- func (c *Cache) StartCron(ctx context.Context)
Constants ¶
This section is empty.
Variables ¶
var ( // ErrHostnameRequired is returned if the given hostName to New is not given. ErrHostnameRequired = errors.New("hostName is required") // ErrHostnameMustNotContainScheme is returned if the given hostName to New contained a scheme. ErrHostnameMustNotContainScheme = errors.New("hostName must not contain scheme") // ErrHostnameNotValid is returned if the given hostName to New is not valid. ErrHostnameNotValid = errors.New("hostName is not valid") // ErrHostnameMustNotContainPath is returned if the given hostName to New contained a path. ErrHostnameMustNotContainPath = errors.New("hostName must not contain a path") )
Functions ¶
This section is empty.
Types ¶
type Cache ¶
type Cache struct {
// contains filtered or unexported fields
}
Cache represents the main cache service.
func New ¶
func New( ctx context.Context, hostName string, db *database.Queries, configStore storage.ConfigStore, narInfoStore storage.NarInfoStore, narStore storage.NarStore, secretKeyPath string, ) (*Cache, error)
New returns a new Cache.
func (*Cache) AddLRUCronJob ¶
AddLRUCronJob adds a job for LRU.
func (*Cache) AddUpstreamCaches ¶
AddUpstreamCaches adds one or more upstream caches.
func (*Cache) DeleteNarInfo ¶
DeleteNarInfo deletes the narInfo from the store.
func (*Cache) GetNar ¶
GetNar returns the nar given a hash and compression from the store. If the nar is not found in the store, it's pulled from an upstream, stored in the stored and finally returned. NOTE: It's the caller responsibility to close the body.
func (*Cache) GetNarInfo ¶
GetNarInfo returns the narInfo given a hash from the store. If the narInfo is not found in the store, it's pulled from an upstream, stored in the stored and finally returned.
func (*Cache) PutNarInfo ¶
PutNarInfo records the narInfo (given as an io.Reader) into the store and signs it.
func (*Cache) SetCacheSignNarinfo ¶
SetCacheSignNarinfo configure ncps to sign or not sign narinfos.
func (*Cache) SetMaxSize ¶
SetMaxSize sets the maxsize of the cache. This will be used by the LRU cronjob to automatically clean-up the store.
func (*Cache) SetRecordAgeIgnoreTouch ¶
SetRecordAgeIgnoreTouch changes the duration at which a record is considered up to date and a touch is not invoked.