Categorygithub.com/filecoin-project/go-storedcounter
modulepackage
0.1.0
Repository: https://github.com/filecoin-project/go-storedcounter.git
Documentation: pkg.go.dev

# README

go-storedcounter

A simple thread safe persisted counter

Table of Contents

Description

The module provides a simple counter on top of a go-ipfs-datastore interface

Install

go get github.com/filecoin-project/go-storedcounter

Usage

Create/load a counter for a datastore and key:

import(
  "github.com/ipfs/go-datastore"
  "github.com/filecoin-project/go-storedcounter"
)

var ds datastore.Datastore
var name datastore.Key

storedCounter := storedcounter.New(ds, name)

Get the next value (will start at 0):

next := storedcCounter.Next()

License

Dual-licensed under MIT + Apache 2.0

# Functions

New returns a new StoredCounter for the given datastore and key.

# Structs

StoredCounter is a counter that persists to a datastore as it increments.