zelin44913 / go-storedcounter2

Simple stored counter

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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

About

Simple stored counter

License:Other


Languages

Language:Go 91.4%Language:Makefile 8.6%