-
Notifications
You must be signed in to change notification settings - Fork 48
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat - add candiutils redis locker with options
- Loading branch information
Showing
7 changed files
with
58 additions
and
45 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,23 @@ | ||
package interfaces | ||
|
||
import "time" | ||
import ( | ||
"time" | ||
|
||
"github.com/golangid/candi/options" | ||
) | ||
|
||
type ( | ||
// Locker abstraction, lock concurrent process | ||
Locker interface { | ||
IsLocked(key string) bool | ||
IsLockedTTL(key string, ttl time.Duration) bool | ||
IsLockedWithOpts(key string, opts ...options.LockerOption) bool | ||
HasBeenLocked(key string) bool | ||
Unlock(key string) | ||
Reset(key string) | ||
Lock(key string, timeout time.Duration) (unlockFunc func(), err error) | ||
GetPrefixLocker() string | ||
GetTTLLocker() time.Duration | ||
IsLockedTTLWithLimit(key string, limit int, TTL time.Duration) bool | ||
Closer | ||
} | ||
) |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
6 changes: 3 additions & 3 deletions
6
mocks/candiutils/LockerOption.go → mocks/options/LockerOption.go
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package options | ||
|
||
import "time" | ||
|
||
type ( | ||
// Options for RedisLocker | ||
LockerOptions struct { | ||
Prefix string | ||
TTL time.Duration | ||
Limit int | ||
} | ||
|
||
// Option function type for setting options | ||
LockerOption func(*LockerOptions) | ||
) |