🚀 add dynamodb

This commit is contained in:
Fenny
2020-11-12 03:34:37 +01:00
parent c0fabf16eb
commit e0f4b3ef34
5 changed files with 93 additions and 0 deletions

65
dynamodb/README.md Normal file
View File

@@ -0,0 +1,65 @@
# DynamoDB
....
### Table of Contents
- [Signatures](#signatures)
- [Installation](#installation)
- [Examples](#examples)
- [Config](#config)
- [Default Config](#default-config)
### Signatures
```go
func New(config ...Config) Storage
var ErrNotExist = errors.New("key does not exist")
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](https://golang.org/dl/) with support for modules. So make sure to initialize one first if you didn't do that yet:
```bash
go mod init github.com/<user>/<repo>
```
And then install the dynamodb implementation:
```bash
go get github.com/gofiber/storage/dynamodb
```
### Examples
Import the storage package.
```go
import "github.com/gofiber/storage/dynamodb"
```
You can use the following possibilities to create a storage:
```go
// Initialize default config
store := dynamodb.New()
// Initialize custom config
store := dynamodb.New(dynamodb.Config{
})
```
### Config
```go
type Config struct {
}
```
### Default Config
```go
var ConfigDefault = Config{
}
```

23
dynamodb/config.go Normal file
View File

@@ -0,0 +1,23 @@
package dynamodb
// Config defines the config for storage.
type Config struct {
}
// ConfigDefault is the default config
var ConfigDefault = Config{}
// configDefault is a helper function to set default values
func configDefault(config ...Config) Config {
// Return default config if nothing provided
if len(config) < 1 {
return ConfigDefault
}
// Override default config
cfg := config[0]
// Set default values
return cfg
}

1
dynamodb/dynamodb.go Normal file
View File

@@ -0,0 +1 @@
package dynamodb

View File

@@ -0,0 +1 @@
package dynamodb

3
dynamodb/go.mod Normal file
View File

@@ -0,0 +1,3 @@
module github.com/gofiber/storage/dynamodb
go 1.14