Skip to content

similar to the watchdog mechanism of Java redission

Notifications You must be signed in to change notification settings

demoManito/watchdog

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

watchdog

The watchdog strategy is a mechanism to automatically detect and handle expired keys.

Quick Start

Based on github.com/redis/go-redis/v9

package main

import (
	"context"
	"fmt"
	"time"

	"github.com/demoManito/watchdog"
	"github.com/go-redis/redis/v9"
)

var (
	client = redis.NewClient(&redis.Options{
		Addr: "localhost:6379",
	})
	
	dog = watchdog.Default()
)

func main() {
	// Add a key with a timeout of 2 second,Renew every (2/3)s intervals
	dog.Watch(client, "key", 2*time.Second, func(ctx context.Context) error {
		// Do something
		return nil
	})
}

About

similar to the watchdog mechanism of Java redission

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages