mirror of
https://github.com/gofiber/storage.git
synced 2025-10-05 08:37:10 +08:00
apply some ai reviews
This commit is contained in:
@@ -3,7 +3,6 @@ package cloudflarekv
|
|||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"context"
|
"context"
|
||||||
"fmt"
|
|
||||||
"os"
|
"os"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
@@ -67,7 +66,6 @@ func Test_CloudflareKV_GetWithContext(t *testing.T) {
|
|||||||
cancel()
|
cancel()
|
||||||
|
|
||||||
val, err = testStore.GetWithContext(ctx, key)
|
val, err = testStore.GetWithContext(ctx, key)
|
||||||
fmt.Println(err)
|
|
||||||
require.ErrorContains(t, err, context.Canceled.Error())
|
require.ErrorContains(t, err, context.Canceled.Error())
|
||||||
require.Nil(t, val)
|
require.Nil(t, val)
|
||||||
|
|
||||||
|
@@ -76,7 +76,7 @@ func New(config Config) *Storage {
|
|||||||
return store
|
return store
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetWithContext value by key with context
|
// GetWithContext retrieves the value associated with the given key using the provided context.
|
||||||
func (s *Storage) GetWithContext(ctx context.Context, key string) ([]byte, error) {
|
func (s *Storage) GetWithContext(ctx context.Context, key string) ([]byte, error) {
|
||||||
k := make(map[string]types.AttributeValue)
|
k := make(map[string]types.AttributeValue)
|
||||||
k[keyAttrName] = &types.AttributeValueMemberS{
|
k[keyAttrName] = &types.AttributeValueMemberS{
|
||||||
|
@@ -62,7 +62,7 @@ func New(config ...Config) *Storage {
|
|||||||
return storage
|
return storage
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetWithContext value by key with context
|
// GetWithContext retrieves the value associated with the given key using the provided context.
|
||||||
func (s *Storage) GetWithContext(ctx context.Context, key string) ([]byte, error) {
|
func (s *Storage) GetWithContext(ctx context.Context, key string) ([]byte, error) {
|
||||||
if len(key) <= 0 {
|
if len(key) <= 0 {
|
||||||
return nil, errors.New("the key value is required")
|
return nil, errors.New("the key value is required")
|
||||||
|
@@ -165,7 +165,7 @@ func New(config ...Config) *Storage {
|
|||||||
return storage
|
return storage
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetWithContext value by key with context
|
// GetWithContext retrieves the value associated with the given key using the provided context.
|
||||||
func (s *Storage) GetWithContext(ctx context.Context, key string) ([]byte, error) {
|
func (s *Storage) GetWithContext(ctx context.Context, key string) ([]byte, error) {
|
||||||
if len(key) <= 0 {
|
if len(key) <= 0 {
|
||||||
return nil, nil
|
return nil, nil
|
||||||
|
@@ -32,7 +32,7 @@ func (s *Storage) DeleteWithContext(ctx context.Context, key string) error
|
|||||||
func (s *Storage) Reset() error
|
func (s *Storage) Reset() error
|
||||||
func (s *Storage) ResetWithContext(ctx context.Context) error
|
func (s *Storage) ResetWithContext(ctx context.Context) error
|
||||||
func (s *Storage) Close() error
|
func (s *Storage) Close() error
|
||||||
func (s *Storage) Conn() *badger.DB
|
func (s *Storage) Conn() *pebble.DB
|
||||||
```
|
```
|
||||||
|
|
||||||
**Note:** The context methods are dummy methods and don't have any functionality, as Pebble does not support context cancellation in its client library. They are provided for compliance with the Fiber storage interface.
|
**Note:** The context methods are dummy methods and don't have any functionality, as Pebble does not support context cancellation in its client library. They are provided for compliance with the Fiber storage interface.
|
||||||
|
@@ -82,7 +82,7 @@ func New(config ...Config) *Storage {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetWithContext value by key with context
|
// GetWithContext retrieves the value associated with the given key using the provided context.
|
||||||
func (s *Storage) GetWithContext(ctx context.Context, key string) ([]byte, error) {
|
func (s *Storage) GetWithContext(ctx context.Context, key string) ([]byte, error) {
|
||||||
if len(key) <= 0 {
|
if len(key) <= 0 {
|
||||||
return nil, nil
|
return nil, nil
|
||||||
|
Reference in New Issue
Block a user