Skip to content
This repository has been archived by the owner on Feb 15, 2023. It is now read-only.

Commit

Permalink
go thunder/reactive: InvalidateAt/After stores expiration time
Browse files Browse the repository at this point in the history
  • Loading branch information
changpingc committed Sep 12, 2018
1 parent 343d127 commit 00f2096
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion reactive/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,15 @@ package reactive
import (
"context"
"time"

"github.com/samsarahq/thunder/thunderpb"
)

func InvalidateAfter(ctx context.Context, d time.Duration) {
r := NewResource()
timer := time.AfterFunc(d, r.Invalidate)
r.Cleanup(func() { timer.Stop() })
AddDependency(ctx, r, nil)
AddDependency(ctx, r, &thunderpb.ExpirationTime{Time: time.Now().Add(d)})
}

func InvalidateAt(ctx context.Context, t time.Time) {
Expand Down

0 comments on commit 00f2096

Please sign in to comment.