Skip to content

Simple Counter, used to count requests or other events, expecially RateLimit.

License

Notifications You must be signed in to change notification settings

go-zoox/counter

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Counter

Simple Counter, used to count requests or other events, expecially RateLimit.

PkgGoDev Build Status Go Report Card Coverage Status GitHub issues Release

Installation

To install the package, run:

go get github.com/go-zoox/counter

Getting Started

import (
  "testing"
  "github.com/go-zoox/counter"
)

func main() {
	id := "127.0.0.1"
	r := counter.New(bucket.NewMemory(), "web", 5*time.Second)

	if err := r.Inc(id); err != nil {
		log.Fatal(err)
	}

	if v, err := r.Count(id); err != nil {
		log.Fatal(err)
	} else {
		fmt.Println("count:", v)
	}
}

Inspired By

  • abo/rerate - redis-based rate counter and rate limiter
  • go-zoox/ratelimit - rate limiter, support in-memory, redis-based, other-databses

License

GoZoox is released under the MIT License.

About

Simple Counter, used to count requests or other events, expecially RateLimit.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages