mirror of
https://github.com/gofiber/storage.git
synced 2025-10-04 08:16:36 +08:00
🚀 add dynamodb
This commit is contained in:
65
dynamodb/README.md
Normal file
65
dynamodb/README.md
Normal 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
23
dynamodb/config.go
Normal 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
1
dynamodb/dynamodb.go
Normal file
@@ -0,0 +1 @@
|
||||
package dynamodb
|
1
dynamodb/dynamodb_test.go
Normal file
1
dynamodb/dynamodb_test.go
Normal file
@@ -0,0 +1 @@
|
||||
package dynamodb
|
3
dynamodb/go.mod
Normal file
3
dynamodb/go.mod
Normal file
@@ -0,0 +1,3 @@
|
||||
module github.com/gofiber/storage/dynamodb
|
||||
|
||||
go 1.14
|
Reference in New Issue
Block a user