modulepackage
0.0.0-20241219022336-5b66685a77c5
Repository: https://github.com/geun-oh/intergration-test.git
Documentation: pkg.go.dev
# README
id: cloudflarekv title: Cloudflare KV
A Cloudflare KV storage driver using cloudflare/cloudflare-go.
Note: Requires Go 1.21 and above
Table of Contents
Signatures
func New(config ...Config) Storage
func (s *Storage) Get(key string) ([]byte, error)
func (s *Storage) Set(key string, val []byte, exp time.Duration) error
func (s *Storage) Delete(key string) error
func (s *Storage) Reset() error
func (s *Storage) Close() error
func (s *Storage) Conn() *cloudflare.API
Installation
go mod init github.com/<user>/<repo>
And then install the Cloudflare KV implementation:
go get github.com/gofiber/storage/cloudflarekv
Examples
Import the storage package.
import "github.com/gofiber/storage/cloudflarekv"
You can use the following possibilities to create a storage.
Key must be an API Token generated with at least Account.Workers KV Storage
permission.
Check Create API Token docs to generate.
// Initialize default config
store := cloudflarekv.New()
store := cloudflarekv.New(cloudflarekv.Config{
Key: "",
Email: "",
AccountID: "fiber",
NamespaceID: "fiber",
Reset: false,
})
Config
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
}
Default Config
var ConfigDefault = Config{
Key: "",
Email: "",
AccountID: "fiber",
NamespaceID: "fiber",
Reset: false,
}
# Functions
No description provided by the author
# Variables
ConfigDefault is the default config.
# Structs
Config defines the config for storage.
No description provided by the author
No description provided by the author