Skip to content
This repository has been archived by the owner on Nov 23, 2018. It is now read-only.

Commit

Permalink
Merge pull request #1 from Hedayet/Hedayet-patch-1
Browse files Browse the repository at this point in the history
Exec the cancel returned by context.WithTimeout
  • Loading branch information
Hedayet authored Mar 30, 2017
2 parents 4954b83 + e5f3762 commit 739fab2
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions timeout.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,17 +22,20 @@ func (s *timeoutManager) Open() (err error) { return s.chain.Open() }
func (s *timeoutManager) Close() (err error) { return s.chain.Close() }

func (s *timeoutManager) Put(ctx context.Context, key string, val []byte) (err error) {
ctx, _ = context.WithTimeout(ctx, s.timeout)
ctx, cancel = context.WithTimeout(ctx, s.timeout)
defer cancel()
return s.chain.Put(ctx, key, val)
}

func (s *timeoutManager) Get(ctx context.Context, key string) (data []byte, err error) {
ctx, _ = context.WithTimeout(ctx, s.timeout)
ctx, cancel = context.WithTimeout(ctx, s.timeout)
defer cancel()
return s.chain.Get(ctx, key)
}

func (s *timeoutManager) Del(ctx context.Context, key string) (err error) {
ctx, _ = context.WithTimeout(ctx, s.timeout)
ctx, cancel = context.WithTimeout(ctx, s.timeout)
defer cancel()
return s.chain.Del(ctx, key)

}

0 comments on commit 739fab2

Please sign in to comment.