Coder Social home page Coder Social logo

go-rede's Introduction

Rede 中文

🚀 A Rede is a fancy snooze delayed queue

You can use the Push method to set a snooze time for an element. Unless the time comes, the element will not wake up. Get the collection of elements that have woken up through the poll method.

Installation

go get -u github.com/fanjindong/go-rede

Features

  • Rede built on redis
  • Snooze time can be updated
  • Api is concise, such as Push, Poll
  • Data persistent storage

Requirements

  • Go >= 1.10.
  • Redis >= 5.0.

Quickstart

func main() {
	rd := rede.NewClient(&rede.Options{Namespaces: "demo", Addr: "127.0.0.1:6379"}) // Redis.Addr + Namespaces

	rd.Push("a", 1*time.Second)
	rd.Push("b", 1*time.Second)
	rd.Push("c", 2*time.Second)

	time.Sleep(1 * time.Second)

	cur := rd.Poll()
	for cur.Next() {
	    got, _ := cur.Get()
	    fmt.Println(got)
	}
	// out:
	// "a" 
	// "b"
}

Usage

  • Push

Push an element to rede and set a snooze time. The element will not wake up until the time is up.

  • Pull

Pull an element and remove it from rede.

  • Look

View the remaining snooze time of an element.

  • Ttn

View the remaining snooze time of the element that wakes up fastest in rede.

  • Poll

Poll the elements that have woken up.

go-rede's People

Contributors

fanjindong avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.