forked from sevtin/lark
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
ec1072d
commit 6529ccf
Showing
12 changed files
with
110 additions
and
19 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 was deleted.
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
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,17 @@ | ||
package xredis | ||
|
||
import ( | ||
"context" | ||
"github.com/go-redsync/redsync/v4" | ||
"time" | ||
) | ||
|
||
func NewMutex(key string, options ...redsync.Option) *redsync.Mutex { | ||
key = RealKey(key) | ||
return Cli.RedsSync.NewMutex(key, options...) | ||
} | ||
|
||
func SetNX(key string, value interface{}, expiration time.Duration) (bool, error) { | ||
key = RealKey(key) | ||
return Cli.Client.SetNX(context.Background(), key, value, expiration).Result() | ||
} |
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
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 |
---|---|---|
@@ -0,0 +1,14 @@ | ||
package template | ||
|
||
var InterfacesDigTemplate = ParseTemplate(` | ||
package dig | ||
import ( | ||
"lark/apps/interfaces/internal/service/svc_{{.PackageName}}" | ||
) | ||
func provide{{.UpperServiceName}}() { | ||
container.Provide(svc_{{.PackageName}}.New{{.UpperServiceName}}Service) | ||
} | ||
`) |
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
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,22 @@ | ||
--- | ||
--- Generated by EmmyLua(https://github.com/EmmyLua) | ||
--- Created by saeipi. | ||
--- DateTime: 2023/7/21 2:20 PM | ||
--- | ||
--- | ||
|
||
local product_key = KEYS[1] | ||
local total_num_key = ARGV[1] | ||
local sold_num_key = ARGV[2] | ||
|
||
local values = redis.call('HMGET', product_key, total_num_key, sold_num_key) | ||
if #values ~= 2 then | ||
return 0 | ||
end | ||
|
||
local total_num = tonumber(values[1]) | ||
local sold_num = tonumber(values[2]) | ||
if total_num > sold_num then | ||
return redis.call('HINCRBY', product_key, sold_num_key, 1) | ||
end | ||
return 0 |
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,9 @@ | ||
local KEYS = {"PK_1001"} | ||
local ARGV = {"TOTAL_NUM","SOLD_NUM"} | ||
|
||
|
||
local productKey = KEYS[1] | ||
local totalNumKey = ARGV[1] | ||
local soldNumKey = ARGV[2] | ||
|
||
print("KEY:",productKey,' TOTAL_NUM:', totalNumKey, " SOLD_NUM:", soldNumKey) |