otto

package module
v0.0.15 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 5, 2025 License: Apache-2.0 Imports: 15 Imported by: 0

README

Otto

An S3-FIFO-based cache for big values in Go.

package main

import (
	"fmt"

	"github.com/notfilippo/otto"
)

func main() {
    chunkSize := 1024
    chunkCount := 256
    cache := otto.New(chunkSize, chunkCount)

    cache.Set("key", []byte("value"))

    value := cache.Get("key", nil)
    fmt.Println(string(value))
}

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	Debug = false
)

Functions

func SaveToFile added in v0.0.11

func SaveToFile(c Cache, path string) error

Types

type Cache

type Cache interface {
	Set(key string, val []byte)
	Get(key string, buf []byte) []byte
	Clear()
	Close()

	Entries() uint64

	Serialize(w io.Writer) error
}

func Deserialize

func Deserialize(r io.Reader) (Cache, error)

func LoadFromFile

func LoadFromFile(path string) (Cache, error)

func New

func New(slotSize, slotCount int) Cache

type TrackerCache added in v0.0.11

type TrackerCache struct {
	// contains filtered or unexported fields
}

func NewTracker added in v0.0.11

func NewTracker(c Cache, windows map[string]TrackerWindow) *TrackerCache

func (*TrackerCache) Clear added in v0.0.11

func (s *TrackerCache) Clear()

func (*TrackerCache) Close added in v0.0.11

func (s *TrackerCache) Close()

func (*TrackerCache) Entries added in v0.0.11

func (s *TrackerCache) Entries() uint64

func (*TrackerCache) Get added in v0.0.11

func (s *TrackerCache) Get(key string, buf []byte) []byte

func (*TrackerCache) Hits added in v0.0.11

func (s *TrackerCache) Hits() uint64

func (*TrackerCache) Misses added in v0.0.11

func (s *TrackerCache) Misses() uint64

func (*TrackerCache) Serialize added in v0.0.11

func (s *TrackerCache) Serialize(w io.Writer) error

func (*TrackerCache) Set added in v0.0.11

func (s *TrackerCache) Set(key string, val []byte)

func (*TrackerCache) Sets added in v0.0.11

func (s *TrackerCache) Sets() uint64

func (*TrackerCache) Window added in v0.0.11

func (s *TrackerCache) Window(name string) (uint64, bool)

type TrackerWindow added in v0.0.11

type TrackerWindow struct {
	BucketDuration time.Duration
	BucketCount    int
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL
JackTT - Gopher 🇻🇳