99 "github.com/aws/aws-sdk-go/service/dynamodb/dynamodbattribute"
1010 "github.com/aws/aws-sdk-go/service/dynamodb/expression"
1111 "github.com/go-redis/redis/v8"
12- "log"
1312 "time"
1413)
1514
@@ -68,12 +67,11 @@ func (s *Locker) DynamoDbLock(ctx context.Context, key string, lockTtl time.Dura
6867 // Make the DynamoDB Query API call
6968 result , _ := s .dynamoClient .ScanWithContext (ctx , params )
7069
71- log .Printf ("--------------result.Items: %s" , result .Items )
7270 if len (result .Items ) > 0 {
7371 return false , nil
7472 }
7573
76- insert , errPut := s .dynamoClient .PutItemWithContext (ctx , & dynamodb.PutItemInput {
74+ _ , errPut := s .dynamoClient .PutItemWithContext (ctx , & dynamodb.PutItemInput {
7775 Item : DynamoDbUnlockMarshal (key ),
7876 TableName : aws .String (Prefix ),
7977 })
@@ -82,19 +80,16 @@ func (s *Locker) DynamoDbLock(ctx context.Context, key string, lockTtl time.Dura
8280 return false , errPut
8381 }
8482
85- log .Printf ("--------------insert: %s" , insert )
86-
8783 return true , nil
8884
8985}
9086
9187func (s * Locker ) DynamoDbUnlock (ctx context.Context , key string ) error {
9288 if s .dynamoClient != nil {
93- item , _ : = s .dynamoClient .DeleteItemWithContext (ctx , & dynamodb.DeleteItemInput {
89+ _ , _ = s .dynamoClient .DeleteItemWithContext (ctx , & dynamodb.DeleteItemInput {
9490 Key : DynamoDbUnlockMarshal (key ),
9591 TableName : aws .String (Prefix ),
9692 })
97- log .Printf ("DynamoDbUnlock:%s\n " , item )
9893 }
9994 return nil
10095}
0 commit comments