otto

package module
v0.0.10 Latest Latest
Warning

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

Go to latest
Published: Feb 25, 2025 License: Apache-2.0 Imports: 12 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

This section is empty.

Types

type Cache

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

	Metrics() Metrics

	SaveToFile(path string) error
	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 Metrics added in v0.0.10

type Metrics struct {
	Entries uint64

	WindowEntrySizeAvg    float64
	WindowEntryInsertions uint64
	WindowEntryEvictions  uint64
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL