Skip to content

Latest commit

 

History

History
19 lines (15 loc) · 331 Bytes

README.md

File metadata and controls

19 lines (15 loc) · 331 Bytes

Usage

lease the resource for duration. When the lease expires, invoke func

Example

package main 

import (
	"github.com/donutloop/toolkit/lease"
)

func main() {
    leaser := lease.NewLeaser()
    leaser.Lease("cleanup-cache", time.Duration(1*time.Second), func() {
    	fmt.Println("cleaned up cache")
    })
}