Documentation ¶
Index ¶
- Constants
- func NewCache(dirpath string, ledgerFile *os.File) pokeapi.Cache
- type Cache
- type Ledger
- func (l *Ledger) Bytes() []byte
- func (l *Ledger) Entry() LedgerEntry
- func (l *Ledger) IsUniq(filename string) bool
- func (l *Ledger) Log(entry LedgerEntry)
- func (l *Ledger) Parse(data []byte) (LedgerEntry, error)
- func (l *Ledger) Read()
- func (l *Ledger) Restore(c *Cache) error
- func (l *Ledger) Scan() bool
- func (l *Ledger) Text() string
- type LedgerEntry
- type List
- func (l *List) Capacity() int
- func (l *List) Empty() bool
- func (l *List) Entry() LedgerEntry
- func (l *List) Full() bool
- func (l *List) Pop() (LedgerEntry, bool)
- func (l *List) Push(entry LedgerEntry) bool
- func (l *List) Remove(entry LedgerEntry)
- func (l *List) Reset() bool
- func (l *List) Scan() bool
- func (l *List) Setup(entries []LedgerEntry)
- func (l *List) Size() int
- type Msg
- type Node
Constants ¶
View Source
const ( READ Msg = "READ" WRITE = "WRITE" EVICT = "EVICT" )
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Cache ¶
type Cache struct {
// contains filtered or unexported fields
}
func (*Cache) Add ¶
Add will add the url and data response to the cache. Internally, it interacts with the ledger by first checking to see if there is room, and inserting if the cache has capacity. Otherwise, it checks the least recently updated (LRU) entry, and removes the lru file. At which point, the cache is fine to write to, and the url and data is persisted.
type Ledger ¶
type Ledger struct {
// contains filtered or unexported fields
}
func (*Ledger) Entry ¶
func (l *Ledger) Entry() LedgerEntry
Entry returns the next LedgerEntry in the ledgerFile function panics if encountering an error parsing the entry.
func (*Ledger) Log ¶
func (l *Ledger) Log(entry LedgerEntry)
type LedgerEntry ¶
type List ¶
type List struct {
// contains filtered or unexported fields
}
func (*List) Entry ¶
func (l *List) Entry() LedgerEntry
func (*List) Pop ¶
func (l *List) Pop() (LedgerEntry, bool)
func (*List) Push ¶
func (l *List) Push(entry LedgerEntry) bool
func (*List) Remove ¶
func (l *List) Remove(entry LedgerEntry)
func (*List) Setup ¶
func (l *List) Setup(entries []LedgerEntry)
type Node ¶
type Node struct { Value LedgerEntry Next *Node }
Click to show internal directories.
Click to hide internal directories.