Documentation
¶
Index ¶
- func DBPath() (string, error)
- type BBoltStore
- type Cache
- func (c *Cache) Clear() error
- func (c *Cache) Close()
- func (c *Cache) Get(url string) (*scrape.Page, string)
- func (c *Cache) GetRaw(url string) (string, string, *scrape.Page)
- func (c *Cache) Put(url string, page *scrape.Page, source string)
- func (c *Cache) PutRaw(url string, page *scrape.Page, source, rawHTML string)
- func (c *Cache) Stats() (entries int, bytes int64)
- type Store
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type BBoltStore ¶
type BBoltStore struct {
// contains filtered or unexported fields
}
BBoltStore implements Store using an embedded bbolt database.
func NewBBoltStore ¶
func NewBBoltStore(path string) (*BBoltStore, error)
NewBBoltStore opens or creates a bbolt database at the given path.
func NewBBoltStoreReadOnly ¶
func NewBBoltStoreReadOnly(path string) (*BBoltStore, error)
NewBBoltStoreReadOnly opens a bbolt database for reading. Use when another process may hold the write lock.
func (*BBoltStore) Clear ¶
func (s *BBoltStore) Clear() error
func (*BBoltStore) Close ¶
func (s *BBoltStore) Close() error
func (*BBoltStore) Stats ¶
func (s *BBoltStore) Stats() (entries int, sizeBytes int64)
type Cache ¶
type Cache struct {
// contains filtered or unexported fields
}
Cache provides TTL-based page caching backed by a Store.
func New ¶
New creates a cache with the default bbolt backend. Returns nil if the cache cannot be initialized.
func NewFromConfig ¶
NewFromConfig creates a cache with the TTL parsed from cfg.CacheTTL, falling back to one hour if the value doesn't parse. Returns nil (a valid, no-op cache — all methods are nil-safe) if the cache cannot be initialized.
func NewReadOnly ¶
func NewReadOnly() *Cache
NewReadOnly opens the cache for reading only. Use for stats/inspection when another process may hold the write lock.
func NewWithStore ¶
NewWithStore builds a cache over a caller-supplied Store. Used by tests to isolate the cache (temp bbolt path) from the user's real cache dir.
func (*Cache) Get ¶
Get looks up a cached page by URL. Returns (nil, "") if missing or expired. The second return is the fetch source recorded at Put time (scrape.SourceHTTP or scrape.SourceBrowser); empty for entries written before source tracking.
func (*Cache) GetRaw ¶
GetRaw looks up a cached entry's raw HTML by URL. Returns (rawHTML, source, page). It is a hit only when the entry exists, is fresh, AND has non-empty RawHTML — a markdown-only entry must not poison a --raw request (serving empty HTML). On miss or empty raw, returns ("", "", nil) so the caller refetches and back-fills.