mirror of
https://github.com/gofiber/storage.git
synced 2025-10-05 00:33:03 +08:00
![dependabot[bot]](/assets/img/avatar_default.png)
Bumps [github.com/aws/aws-sdk-go](https://github.com/aws/aws-sdk-go) from 1.38.51 to 1.38.52. - [Release notes](https://github.com/aws/aws-sdk-go/releases) - [Changelog](https://github.com/aws/aws-sdk-go/blob/main/CHANGELOG.md) - [Commits](https://github.com/aws/aws-sdk-go/compare/v1.38.51...v1.38.52) --- updated-dependencies: - dependency-name: github.com/aws/aws-sdk-go dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
⚠ DynamoDB is still in development, do not use in production!
....
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
Installation
DynamoDB is tested on the 2 last Go versions with support for modules. So make sure to initialize one first if you didn't do that yet:
go mod init github.com/<user>/<repo>
And then install the dynamodb implementation:
go get github.com/gofiber/storage/dynamodb
Examples
Import the storage package.
import "github.com/gofiber/storage/dynamodb"
You can use the following possibilities to create a storage:
// Initialize dynamodb
store := dynamodb.New(dynamodb.Config{
})
Config
type Config struct {
// Region of the DynamoDB service you want to use.
// Valid values: https://docs.aws.amazon.com/general/latest/gr/rande.html#ddb_region.
// E.g. "us-west-2".
// Optional (read from shared config file or environment variable if not set).
// Environment variable: "AWS_REGION".
Region string
// Name of the DynamoDB table.
// Optional ("fiber_storage" by default).
Table string
// AWS access key ID (part of the credentials).
// Optional (read from shared credentials file or environment variable if not set).
// Environment variable: "AWS_ACCESS_KEY_ID".
AWSaccessKeyID string
// AWS secret access key (part of the credentials).
// Optional (read from shared credentials file or environment variable if not set).
// Environment variable: "AWS_SECRET_ACCESS_KEY".
AWSsecretAccessKey string
// CustomEndpoint allows you to set a custom DynamoDB service endpoint.
// This is especially useful if you're running a "DynamoDB local" Docker container for local testing.
// Typical value for the Docker container: "http://localhost:8000".
// See https://hub.docker.com/r/amazon/dynamodb-local/.
// Optional ("" by default)
CustomEndpoint string
}
Default Config
var ConfigDefault = Config{
Table: "fiber_storage",
}