arc

package module
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Jan 9, 2026 License: Apache-2.0, MIT Imports: 5 Imported by: 1

README

go-ds-arc

This is an IPFS datastore implementation backed by an Adaptive Replacement Cache (ARC).

From golang-lru/arc:

ARC is an enhancement over the standard LRU cache in that tracks both frequency and recency of use. This avoids a burst in access to new entries from evicting the frequently used older entries. It adds some additional tracking overhead to a standard LRU cache, computationally it is roughly 2x the cost, and the extra memory overhead is linear with the size of the cache. ARC has been patented by IBM, but is similar to the TwoQueueCache (2Q) which requires setting parameters.

Install

go get github.com/storacha/go-ds-arc

Usage

package main

import "github.com/storacha/go-ds-arc"

func main() {
  capacity := 1000

  // create a datastore with capacity for 1,000 items
  ds, err := arc.New(capacity)

  // use as per https://github.com/ipfs/go-datastore
}
API

pkg.go.dev Reference

Contributing

Feel free to join in. All welcome. Please open an issue!

License

Dual-licensed under MIT OR Apache 2.0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ARCDS

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

func New

func New(size int) *ARCDS

func (*ARCDS) Batch

func (a *ARCDS) Batch(ctx context.Context) (datastore.Batch, error)

func (*ARCDS) Close

func (a *ARCDS) Close() error

func (*ARCDS) Delete

func (a *ARCDS) Delete(ctx context.Context, key datastore.Key) error

func (*ARCDS) Get

func (a *ARCDS) Get(ctx context.Context, key datastore.Key) (value []byte, err error)

func (*ARCDS) GetSize

func (a *ARCDS) GetSize(ctx context.Context, key datastore.Key) (size int, err error)

func (*ARCDS) Has

func (a *ARCDS) Has(ctx context.Context, key datastore.Key) (exists bool, err error)

func (*ARCDS) Put

func (a *ARCDS) Put(ctx context.Context, key datastore.Key, value []byte) error

func (*ARCDS) Query

func (a *ARCDS) Query(ctx context.Context, q query.Query) (query.Results, error)

func (*ARCDS) Sync

func (a *ARCDS) Sync(ctx context.Context, prefix datastore.Key) error

Jump to

Keyboard shortcuts

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