A Go implementation of Rust's evmap

go-evmap

A Go implementation of Rust's evmap. This implementation is more of a naive implementation that does not support writer/reader handles and iterators, but this also means that the implementation is extremely simple (<200 lines). It has no direct dependencies.

Usage

cache := eventual.NewMap[string, int]()

// Insert a key
cache.Insert("foo", 0)
cache.Has("foo") // false

// Explicitly expose the current state of the map to the reads
cache.Refresh()
cache.Has("foo") // true

Why?

This data structure is optimized for high-read, low-write workloads where readers never have to coordinate with writers. This lack of coordination comes at a cost, "The trade-off exposed by this module is one of eventual consistency: writes are not visible to readers except following explicit synchronization. Specifically, readers only see the operations that preceded the last call to Refresh by a writer. This lets writers decide how stale they are willing to let reads get. They can refresh the map after every write to emulate a regular map, or they can refresh only occasionally to reduce the synchronization overhead at the cost of stale reads." (evmap readme)

Features

  • Readers never block writers
  • Writers never block readers
  • Reads and writes are completely thread-safe
  • 100% test coverage
  • Utilizes Go 1.18 generics

Caveats

  • Readers do not observe writes as they occur (eventual consistency)
  • Writers block other writers (writes are guarded by a mutex).

Help Needed

I do not have the expertise to benchmark this. I've implemented a crude benchmark in map_bench_test.go but the results are all across the board.

Similar Resources

Implementation of the test task, chat in the goland language

Implementation of the test task, chat in the goland language

Implementation of the test task, chat in the goland language

Dec 5, 2021

Rule engine implementation in Golang

Rule engine implementation in Golang

Rule engine implementation in Golang

Dec 30, 2022

Refrence implementation of the globaldce protocol

globaldce-toolbox This is the reference implementation of globaldce protocole coded in the go programming language. This project is still experimental

Dec 14, 2022

The official golang implementation for Project Anatha.

Project Anatha The official golang implementation for Project Anatha. For instructions on setting up a validator on the Anatha network, view the guide

Nov 25, 2021

The official Go implementation for interacting with the TonicPow API

The official Go implementation for interacting with the TonicPow API

The official Go implementation for interacting with the TonicPow API Table of Contents Installation Documentation Examples & Tests Benchmarks Code Sta

Jan 17, 2022

An ease to use finit state machine golang implementation.Turn any struct to a fsm with graphviz visualization supported.

go-fsm An ease to use finit state machine golang implementation.Turn any struct to a fsm with graphviz visualization supported. usage import github.co

Dec 26, 2021

gopbin is a minimalist and opinionated pastebin implementation written in Go.

gopbin gopbin is a minimalist and opinionated pastebin implementation written in

Dec 28, 2021

Flesch-go - Go-based implementation of the Flesch reading ease readability formula module.

flesch-go Go-based implementation of the Flesch reading ease readability formula module. Thanks for the flesch-index project. Installation Run the fol

Nov 9, 2022

This project is an implementation of Fermat's factorization method in which multiples of prime numbers are factored into their constituent primes

This project is an implementation of Fermat's factorization method in which multiples of prime numbers are factored into their constituent primes. It is a vanity attempt to break RSA Encryption which relies on prime multiples for encryption.

Jun 3, 2022
Go implementation of the Rust `dbg` macro

godbg ?? godbg is an implementation of the Rust2018 builtin debugging macro dbg. The purpose of this package is to provide a better and more effective

Dec 14, 2022
Functional programming library for Go including a lazy list implementation and some of the most usual functions.

functional A functional programming library including a lazy list implementation and some of the most usual functions. import FP "github.com/tcard/fun

May 21, 2022
Go implementation of the XDG Base Directory Specification and XDG user directories

xdg Provides an implementation of the XDG Base Directory Specification. The specification defines a set of standard paths for storing application file

Dec 23, 2022
Simple Client Implementation of WebFinger

Go-Webfinger Go client for the Webfinger protocol Go-Webfinger is a Go client for the Webfinger protocol. *It is a work in progress, the API is not fr

Nov 18, 2022
An example client implementation written in GO to access the CyberVox platform API

About This is an example client implementation written in GO to access the CyberVox platform API.

Nov 7, 2022
An implementation of standard generics APIs in Go.

generics This package shows an implementation outlook of proposed generics APIs import "changkun.de/x/generics" Related issues: golang/go#45458 golang

Dec 5, 2022
a quick golang implementation of google pubsub subscriber for testing with the emulator.

gosub a quick golang implementation of google pubsub subscriber for testing with the emulator. it does one thing which is subscribing to a topic and r

Oct 23, 2021
Go implementation Welford’s method for one-pass variance computation

Variance and standard deviation caluculation using variance's algorithm Table of Contents Introduction Installation Usage Contributing License Introdu

Jun 5, 2022
Go implementation of Donald Knuth's Algorithm 7.2.2.1C for exact cover with colors.

go-dlx Go implementation of Donald Knuth's Algorithm 7.2.2.1C for exact cover with colors. This code is based on the Algorithm C described in http://w

Dec 14, 2022
A simple and sussy project is an implementation of SOMMIP Lab 1 written in Golang
A simple and sussy project is an implementation of SOMMIP Lab 1 written in Golang

SOMMIP Lab 1 Isac Arthur Table of Contents About The Project Getting Started Prerequisites Installation Supported commands About The Project This very

Nov 10, 2021