| id | cloudflarekv |
|---|---|
| title | Cloudflare KV |
A Cloudflare KV storage driver using cloudflare/cloudflare-go.
func New(config ...Config) Storage
func (s *Storage) Get(key string) ([]byte, error)
func (s *Storage) GetWithContext(ctx context.Context, key string) ([]byte, error)
func (s *Storage) Set(key string, val []byte, exp time.Duration) error
func (s *Storage) SetWithContext(ctx context.Context, key string, val []byte, exp time.Duration) error
func (s *Storage) Delete(key string) error
func (s *Storage) DeleteWithContext(ctx context.Context, key string) error
func (s *Storage) Reset() error
func (s *Storage) ResetWithContext(ctx context.Context) error
func (s *Storage) Close() error
func (s *Storage) Conn() *cloudflare.APIgo mod init github.com/<user>/<repo>And then install the Cloudflare KV implementation:
go get github.com/gofiber/storage/cloudflarekvImport the storage package.
import "github.com/gofiber/storage/cloudflarekv"You can use the following methods to create storage. The Key must be an API Token generated with at least Account.Workers KV Storage permission. Check the Create API Token documentation to generate one.
// Initialize default config
store := cloudflarekv.New()
store := cloudflarekv.New(cloudflarekv.Config{
Key: "",
Email: "",
AccountID: "fiber",
NamespaceID: "fiber",
Reset: false,
})type Config struct {
// Cloudflare Auth Token
//
// Optional. Default is ""
Key string
// Cloudflare Email
//
// Optional. Default is ""
Email string
// Account id
//
// Optional. Default is "fiber"
AccountID string
// Namespace id
//
// Optional. Default is "fiber"
NamespaceID string
// Reset clears any existing keys in existing Table
//
// Optional. Default is false
Reset bool
}var ConfigDefault = Config{
Key: "",
Email: "",
AccountID: "fiber",
NamespaceID: "fiber",
Reset: false,
}