func (s *Storage) Delete(key string) error {
	if err := s.initConfig(); err != nil {
		return err
	}
	if key == "" {
		return errors.New("key must not be empty")
	}
	svc := dynamodb.New(s.AwsSession)
	input := &dynamodb.DeleteItemInput{
		Key: map[string]*dynamodb.AttributeValue{
			primaryKeyAttribute: {
				S: aws.String(key),
			},
		},
		TableName: aws.String(s.Table),
	}
	_, err := svc.DeleteItem(input)
	if err != nil {
		return err
	}
	return nil
}
Delete deletes key.
package dynamodbstorage
import (
	"context"
	"encoding/base64"
	"errors"
	"fmt"
	"log"
	"time"
	"github.com/aws/aws-sdk-go/aws"
	"github.com/aws/aws-sdk-go/aws/session"
	"github.com/aws/aws-sdk-go/service/dynamodb"
	"github.com/aws/aws-sdk-go/service/dynamodb/dynamodbattribute"
	caddy "github.com/caddyserver/caddy/v2"
	"github.com/caddyserver/certmagic"
)
const (
	contentsAttribute    = "Contents"
	primaryKeyAttribute  = "PrimaryKey"
	lastUpdatedAttribute = "LastUpdated"
	lockTimeoutMinutes   = caddy.Duration(5 * time.Minute)
	lockPollingInterval  = caddy.Duration(5 * time.Second)
)
type Item struct {
	PrimaryKey  string    `json:"PrimaryKey"`
	Contents    string    `json:"Contents"`
	LastUpdated time.Time `json:"LastUpdated"`
}
type Storage struct {
	Table               string           `json:"table,omitempty"`
	AwsSession          *session.Session `json:"-"`
	AwsEndpoint         string           `json:"aws_endpoint,omitempty"`
	AwsRegion           string           `json:"aws_region,omitempty"`
	AwsDisableSSL       bool             `json:"aws_disable_ssl,omitempty"`
	LockTimeout         caddy.Duration   `json:"lock_timeout,omitempty"`
	LockPollingInterval caddy.Duration   `json:"lock_polling_interval,omitempty"`
}
func (s *Storage) initConfig() error {
	if s.Table == "" {
		return errors.New("config error: table name is required")
	}
	if s.LockTimeout == 0 {
		s.LockTimeout = lockTimeoutMinutes
	}
	if s.LockPollingInterval == 0 {
		s.LockPollingInterval = lockPollingInterval
	}
	if s.AwsSession == nil {
		var err error
		s.AwsSession, err = session.NewSession(&aws.Config{
			Endpoint:   &s.AwsEndpoint,
			Region:     &s.AwsRegion,
			DisableSSL: &s.AwsDisableSSL,
		})
		if err != nil {
			return err
		}
	}
	return nil
}
func (s *Storage) Store(key string, value []byte) error {
	if err := s.initConfig(); err != nil {
		return err
	}
	encVal := base64.StdEncoding.EncodeToString(value)
	if key == "" {
		return errors.New("key must not be empty")
	}
	svc := dynamodb.New(s.AwsSession)
	input := &dynamodb.PutItemInput{
		Item: map[string]*dynamodb.AttributeValue{
			primaryKeyAttribute: {
				S: aws.String(key),
			},
			contentsAttribute: {
				S: aws.String(encVal),
			},
			lastUpdatedAttribute: {
				S: aws.String(time.Now().Format(time.RFC3339)),
			},
		},
		TableName: aws.String(s.Table),
	}
	_, err := svc.PutItem(input)
	return err
}
func (s *Storage) Load(key string) ([]byte, error) {
	if err := s.initConfig(); err != nil {
		return []byte{}, err
	}
	if key == "" {
		return []byte{}, errors.New("key must not be empty")
	}
	domainItem, err := s.getItem(key)
	return []byte(domainItem.Contents), err
}