Skip to content

Commit 36dce0f

Browse files
1 parent f7c8572 commit 36dce0f

File tree

31 files changed

+3818
-0
lines changed

31 files changed

+3818
-0
lines changed
Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
---
2+
title: 👋 Welcome
3+
description: 📦 Premade storage drivers for 🚀 Fiber.
4+
sidebar_position: 1
5+
---
6+
7+
<p align="center">
8+
<img height="125" alt="Fiber" src="https://raw.githubusercontent.com/gofiber/storage/master/.github/logo-dark.svg#gh-dark-mode-only" />
9+
<img height="125" alt="Fiber" src="https://raw.githubusercontent.com/gofiber/storage/master/.github/logo.svg#gh-light-mode-only" />
10+
<br/>
11+
12+
<a href="https://pkg.go.dev/github.com/gofiber/storage?tab=doc">
13+
<img src="https://img.shields.io/badge/%F0%9F%93%9A%20godoc-pkg-00ACD7.svg?color=00ACD7&style=flat"/>
14+
</a>
15+
<a href="https://goreportcard.com/report/github.com/gofiber/storage">
16+
<img src="https://img.shields.io/badge/%F0%9F%93%9D%20goreport-A%2B-75C46B"/>
17+
</a>
18+
<a href="https://gofiber.io/discord">
19+
<img src="https://img.shields.io/discord/704680098577514527?style=flat&label=%F0%9F%92%AC%20discord&color=00ACD7"/>
20+
</a>
21+
</p>
22+
23+
Premade storage drivers that implement the [`Storage`](https://github.com/gofiber/storage/blob/main/storage.go) interface, designed to be used with various [Fiber middlewares](https://github.com/gofiber/fiber/tree/master/middleware).
24+
25+
```go
26+
// Storage interface for communicating with different database/key-value
27+
// providers. Visit https://github.com/gofiber/storage for more info.
28+
type Storage interface {
29+
// Get gets the value for the given key.
30+
// `nil, nil` is returned when the key does not exist
31+
Get(key string) ([]byte, error)
32+
33+
// Set stores the given value for the given key along
34+
// with an expiration value, 0 means no expiration.
35+
// Empty key or value will be ignored without an error.
36+
Set(key string, val []byte, exp time.Duration) error
37+
38+
// Delete deletes the value for the given key.
39+
// It returns no error if the storage does not contain the key,
40+
Delete(key string) error
41+
42+
// Reset resets the storage and delete all keys.
43+
Reset() error
44+
45+
// Close closes the storage and will stop any running garbage
46+
// collectors and open connections.
47+
Close() error
48+
}
49+
```
50+
51+
## 📑 Storage Implementations
52+
53+
- [ArangoDB](./arangodb/README.md) <a href="https://github.com/gofiber/storage/actions?query=workflow%3A%22Tests+ArangoDB%22"> <img src="https://img.shields.io/github/actions/workflow/status/gofiber/storage/test-arangodb.yml?branch=main&label=%F0%9F%A7%AA%20&style=flat&color=75C46B" /> </a>
54+
- [AzureBlob](./azureblob/README.md) <a href="https://github.com/gofiber/storage/actions?query=workflow%3A%22Tests+Azure+Blob%22"> <img src="https://img.shields.io/github/actions/workflow/status/gofiber/storage/test-azureblob.yml?branch=main&label=%F0%9F%A7%AA%20&style=flat&color=75C46B" /> </a>
55+
- [Badger](./badger/README.md) <a href="https://github.com/gofiber/storage/actions?query=workflow%3A%22Tests+Badger%22"> <img src="https://img.shields.io/github/actions/workflow/status/gofiber/storage/test-badger.yml?branch=main&label=%F0%9F%A7%AA%20&style=flat&color=75C46B" /> </a>
56+
- [Bbolt](./bbolt) <a href="https://github.com/gofiber/storage/actions?query=workflow%3A%22Tests+Bbolt%22"> <img src="https://img.shields.io/github/actions/workflow/status/gofiber/storage/test-bbolt.yml?branch=main&label=%F0%9F%A7%AA%20&style=flat&color=75C46B" /> </a>
57+
- [CloudflareKV](./cloudflarekv/README.md) <a href="https://github.com/gofiber/storage/actions?query=workflow%3A%22Tests+CloudflareKV%22"> <img src="https://img.shields.io/github/actions/workflow/status/gofiber/storage/test-cloudflarekv.yml?branch=main&label=%F0%9F%A7%AA%20&style=flat&color=75C46B" /> </a>
58+
- [Coherence](./coherence/README.md) <a href="https://github.com/gofiber/storage/actions?query=workflow%3A%22Tests+Coherence%22"> <img src="https://img.shields.io/github/actions/workflow/status/gofiber/storage/test-coherence.yml?branch=main&label=%F0%9F%A7%AA%20&style=flat&color=75C46B" /> </a>
59+
- [Couchbase](./couchbase/README.md) <a href="https://github.com/gofiber/storage/actions?query=workflow%3A%22Tests+Couchbase%22"> <img src="https://img.shields.io/github/actions/workflow/status/gofiber/storage/test-couchbase.yml?branch=main&label=%F0%9F%A7%AA%20&style=flat&color=75C46B" /> </a>
60+
- [DynamoDB](./dynamodb/README.md) <a href="https://github.com/gofiber/storage/actions?query=workflow%3A%22Tests+DynamoDB%22"> <img src="https://img.shields.io/github/actions/workflow/status/gofiber/storage/test-dynamodb.yml?branch=main&label=%F0%9F%A7%AA%20&style=flat&color=75C46B" /> </a>
61+
- [Etcd](./etcd/README.md) <a href="https://github.com/gofiber/storage/actions?query=workflow%3A%22Tests+Etcd%22"> <img src="https://img.shields.io/github/actions/workflow/status/gofiber/storage/test-etcd.yml?branch=main&label=%F0%9F%A7%AA%20&style=flat&color=75C46B" /> </a>
62+
- [Memcache](./memcache/README.md) <a href="https://github.com/gofiber/storage/actions?query=workflow%3A%22Tests+Memcache%22"> <img src="https://img.shields.io/github/actions/workflow/status/gofiber/storage/test-memcache.yml?branch=main&label=%F0%9F%A7%AA%20&style=flat&color=75C46B" /> </a>
63+
- [Memory](./memory/README.md) <a href="https://github.com/gofiber/storage/actions?query=workflow%3A%22Tests+Local+Storage%22"> <img src="https://img.shields.io/github/actions/workflow/status/gofiber/storage/test-memory.yml?branch=main&label=%F0%9F%A7%AA%20&style=flat&color=75C46B" /> </a>
64+
- [Minio](./minio/README.md) <a href="https://github.com/gofiber/storage/actions?query=workflow%3A%22Tests+Minio%22"> <img src="https://img.shields.io/github/actions/workflow/status/gofiber/storage/test-minio.yml?branch=main&label=%F0%9F%A7%AA%20&style=flat&color=75C46B" /> </a>
65+
- [MockStorage](./mockstorage/README.md) <a href="https://github.com/gofiber/storage/actions?query=workflow%3A%22Tests+MockStorage%22"> <img src="https://img.shields.io/github/actions/workflow/status/gofiber/storage/test-mockstorage.yml?branch=main&label=%F0%9F%A7%AA%20&style=flat&color=75C46B" /> </a>
66+
- [MongoDB](./mongodb/README.md) <a href="https://github.com/gofiber/storage/actions?query=workflow%3A%22Tests+Mongodb%22"> <img src="https://img.shields.io/github/actions/workflow/status/gofiber/storage/test-mongodb.yml?branch=main&label=%F0%9F%A7%AA%20&style=flat&color=75C46B" /> </a>
67+
- [MSSQL](./mssql/README.md) <a href="https://github.com/gofiber/storage/actions?query=workflow%3A%22Tests+MSSQL%22"> <img src="https://img.shields.io/github/actions/workflow/status/gofiber/storage/test-mssql.yml?branch=main&label=%F0%9F%A7%AA%20&style=flat&color=75C46B" /> </a>
68+
- [MySQL](./mysql/README.md) <a href="https://github.com/gofiber/storage/actions?query=workflow%3A%22Tests+MySQL%22"> <img src="https://img.shields.io/github/actions/workflow/status/gofiber/storage/test-mysql.yml?branch=main&label=%F0%9F%A7%AA%20&style=flat&color=75C46B" /> </a>
69+
- [NATS](./nats/README.md) <a href="https://github.com/gofiber/storage/actions?query=workflow%3A%22Tests%20Nats%20Driver%22"> <img src="https://img.shields.io/github/actions/workflow/status/gofiber/storage/test-nats.yml?branch=main&label=%F0%9F%A7%AA%20&style=flat&color=75C46B" /> </a>
70+
- [Neo4j](./neo4j/README.md) <a href="https://github.com/gofiber/storage/actions?query=workflow%3A%22Tests+Neo4j%22"> <img src="https://img.shields.io/github/actions/workflow/status/gofiber/storage/test-neo4j.yml?branch=main&label=%F0%9F%A7%AA%20&style=flat&color=75C46B" /> </a>
71+
- [Pebble](./pebble/README.md) <a href="https://github.com/gofiber/storage/actions?query=workflow%3A%22Tests+Pebble%22"> <img src="https://img.shields.io/github/actions/workflow/status/gofiber/storage/test-pebble.yml?branch=main&label=%F0%9F%A7%AA%20&style=flat&color=75C46B" /> </a>
72+
- [Postgres](./postgres/README.md) <a href="https://github.com/gofiber/storage/actions?query=workflow%3A%22Tests+Postgres%22"> <img src="https://img.shields.io/github/actions/workflow/status/gofiber/storage/test-postgres.yml?branch=main&label=%F0%9F%A7%AA%20&style=flat&color=75C46B" /> </a>
73+
- [Redis](./redis/README.md) <a href="https://github.com/gofiber/storage/actions?query=workflow%3A%22Tests+Redis%22"> <img src="https://img.shields.io/github/actions/workflow/status/gofiber/storage/test-redis.yml?branch=main&label=%F0%9F%A7%AA%20&style=flat&color=75C46B" /> </a>
74+
- [Rueidis](./rueidis/README.md) <a href="https://github.com/gofiber/storage/actions?query=workflow%3A%22Tests+rueidis%22"> <img src="https://img.shields.io/github/actions/workflow/status/gofiber/storage/test-rueidis.yml?branch=main&label=%F0%9F%A7%AA%20&style=flat&color=75C46B" /> </a>
75+
- [S3](./s3/README.md) <a href="https://github.com/gofiber/storage/actions?query=workflow%3A%22Tests+S3%22"> <img src="https://img.shields.io/github/actions/workflow/status/gofiber/storage/test-s3.yml?branch=main&label=%F0%9F%A7%AA%20&style=flat&color=75C46B" /> </a>
76+
- [ScyllaDB](./scylladb/README.md) <a href="https://github.com/gofiber/storage/actions?query=workflow%3A%22Tests+scylladb%22"> <img src="https://img.shields.io/github/actions/workflow/status/gofiber/storage/test-scylladb.yml?branch=main&label=%F0%9F%A7%AA%20&style=flat&color=75C46B" /> </a>
77+
- [SQLite3](./sqlite3/README.md) <a href="https://github.com/gofiber/storage/actions?query=workflow%3A%22Tests+Sqlite3%22"> <img src="https://img.shields.io/github/actions/workflow/status/gofiber/storage/test-sqlite3.yml?branch=main&label=%F0%9F%A7%AA%20&style=flat&color=75C46B" /> </a>
78+
- [ClickHouse](./clickhouse/README.md) <a href="https://github.com/gofiber/storage/actions?query=workflow%3A%22Tests+Clickhouse%22"> <img src="https://img.shields.io/github/actions/workflow/status/gofiber/storage/test-clickhouse.yml?branch=main&label=%F0%9F%A7%AA%20&style=flat&color=75C46B" /> </a>
79+
- [Valkey](./valkey/README.md) <a href="https://github.com/gofiber/storage/actions?query=workflow%3A%22Tests+valkey%22"> <img src="https://img.shields.io/github/actions/workflow/status/gofiber/storage/test-valkey.yml?branch=main&label=%F0%9F%A7%AA%20&style=flat&color=75C46B" /> </a>
Lines changed: 120 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,120 @@
1+
---
2+
id: arangodb
3+
title: ArangoDB
4+
---
5+
6+
![Release](https://img.shields.io/github/v/tag/gofiber/storage?filter=arangodb*)
7+
[![Discord](https://img.shields.io/discord/704680098577514527?style=flat&label=%F0%9F%92%AC%20discord&color=00ACD7)](https://gofiber.io/discord)
8+
![Test](https://img.shields.io/github/actions/workflow/status/gofiber/storage/test-arangodb.yml?label=Tests)
9+
![Security](https://img.shields.io/github/actions/workflow/status/gofiber/storage/gosec.yml?label=Security)
10+
![Linter](https://img.shields.io/github/actions/workflow/status/gofiber/storage/linter.yml?label=Linter)
11+
12+
A ArangoDB storage driver using `arangodb/go-driver` and [arangodb/go-driver](https://github.com/arangodb/go-driver).
13+
14+
**Note: Requires Go 1.19 and above**
15+
16+
### Table of Contents
17+
- [Signatures](#signatures)
18+
- [Installation](#installation)
19+
- [Examples](#examples)
20+
- [Config](#config)
21+
- [Default Config](#default-config)
22+
23+
### Signatures
24+
```go
25+
func New(config ...Config) Storage
26+
func (s *Storage) Get(key string) ([]byte, error)
27+
func (s *Storage) Set(key string, val []byte, exp time.Duration) error
28+
func (s *Storage) Delete(key string) error
29+
func (s *Storage) Reset() error
30+
func (s *Storage) Close() error
31+
func (s *Storage) Conn() driver.Client
32+
```
33+
### Installation
34+
ArangoDB is tested on the 2 last (1.14/1.15) [Go versions](https://golang.org/dl/) with support for modules. So make sure to initialize one first if you didn't do that yet:
35+
```bash
36+
go mod init github.com/<user>/<repo>
37+
```
38+
And then install the arangodb implementation:
39+
```bash
40+
go get github.com/gofiber/storage/arangodb/v2
41+
```
42+
43+
### Examples
44+
Import the storage package.
45+
```go
46+
import "github.com/gofiber/storage/arangodb/v2"
47+
```
48+
49+
You can use the following possibilities to create a storage:
50+
```go
51+
// Initialize default config
52+
store := arangodb.New()
53+
54+
// Initialize custom config
55+
store := arangodb.New(arangodb.Config{
56+
Host: "http://127.0.0.1",
57+
Port: 8529,
58+
Database: "fiber",
59+
Collection: "fiber_storage",
60+
Reset: false,
61+
GCInterval: 10 * time.Second,
62+
})
63+
```
64+
65+
### Config
66+
```go
67+
type Config struct {
68+
// Host name where the DB is hosted
69+
//
70+
// Optional. Default is "http://127.0.0.1"
71+
Host string
72+
73+
// Port where the DB is listening on
74+
//
75+
// Optional. Default is 8529
76+
Port int
77+
78+
// Server username
79+
//
80+
// Optional. Default is ""
81+
Username string
82+
83+
// Server password
84+
//
85+
// Optional. Default is ""
86+
Password string
87+
88+
// Database name
89+
//
90+
// Optional. Default is "fiber"
91+
Database string
92+
93+
// Collection name
94+
//
95+
// Optional. Default is "fiber_storage"
96+
Collection string
97+
98+
// Reset clears any existing keys in existing collection
99+
//
100+
// Optional. Default is false
101+
Reset bool
102+
// Time before deleting expired keys
103+
//
104+
// Optional. Default is 10 * time.Second
105+
GCInterval time.Duration
106+
}
107+
```
108+
109+
### Default Config
110+
Used only for optional fields
111+
```go
112+
var ConfigDefault = Config{
113+
Host: "http://127.0.0.1",
114+
Port: 8529,
115+
Database: "fiber",
116+
Collection: "fiber_storage",
117+
Reset: false,
118+
GCInterval: 10 * time.Second,
119+
}
120+
```
Lines changed: 112 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,112 @@
1+
---
2+
id: azureblob
3+
title: Azure Blob
4+
---
5+
6+
![Release](https://img.shields.io/github/v/tag/gofiber/storage?filter=azureblob*)
7+
[![Discord](https://img.shields.io/discord/704680098577514527?style=flat&label=%F0%9F%92%AC%20discord&color=00ACD7)](https://gofiber.io/discord)
8+
![Test](https://img.shields.io/github/actions/workflow/status/gofiber/storage/test-azureblob.yml?label=Tests)
9+
![Security](https://img.shields.io/github/actions/workflow/status/gofiber/storage/gosec.yml?label=Security)
10+
![Linter](https://img.shields.io/github/actions/workflow/status/gofiber/storage/linter.yml?label=Linter)
11+
12+
[Azure Blob storage](https://azure.microsoft.com/en-us/products/storage/blobs/#overview) is Microsoft's object storage solution for the cloud.
13+
14+
**Note: Requires Go 1.19 and above**
15+
16+
### Table of Contents
17+
18+
- [Signatures](#signatures)
19+
- [Installation](#installation)
20+
- [Examples](#examples)
21+
- [Config](#config)
22+
- [Default Config](#default-config)
23+
24+
### Signatures
25+
26+
```go
27+
func New(config ...Config) Storage
28+
func (s *Storage) Get(key string) ([]byte, error)
29+
func (s *Storage) Set(key string, val []byte, exp time.Duration) error
30+
func (s *Storage) Delete(key string) error
31+
func (s *Storage) Reset() error
32+
func (s *Storage) Close() error
33+
func (s *Storage) Conn() *azblob.Client
34+
```
35+
36+
### Installation
37+
38+
Azure blob storage driver 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:
39+
40+
```bash
41+
go mod init github.com/<user>/<repo>
42+
```
43+
44+
And then install the azure blob implementation:
45+
46+
```bash
47+
go get github.com/gofiber/storage/azureblob/v2
48+
```
49+
50+
### Examples
51+
52+
Import the storage package.
53+
54+
```go
55+
import "github.com/gofiber/storage/azureblob/v2"
56+
```
57+
58+
You can use the following possibilities to create a storage:
59+
60+
```go
61+
// Initialize default config
62+
store := azureblob.New()
63+
64+
// Initialize custom config
65+
store := azureblob.New(azureblob.Config{
66+
Account: "test",
67+
Container: "test",
68+
Credentials: Credentials{
69+
Account: "test",
70+
Key: "YXp1cml0ZWtleQo=",
71+
},
72+
})
73+
```
74+
75+
### Config
76+
77+
```go
78+
type Config struct {
79+
// Storage account name.
80+
Account string
81+
// Container name.
82+
Container string
83+
// Storage endpoint.
84+
// Optional. Default: "https://STORAGEACCOUNTNAME.blob.core.windows.net"
85+
Endpoint string
86+
// Request timeout.
87+
// Optional. Default is 0 (no timeout)
88+
RequestTimeout time.Duration
89+
// Reset clears any existing keys in existing container.
90+
// Optional. Default is false
91+
Reset bool
92+
// Credentials overrides AWS access key and AWS secret access key. Not recommended.
93+
// Optional. Default is Credentials{}
94+
Credentials Credentials
95+
// The maximum number of times requests that encounter retryable failures should be attempted.
96+
// Optional. Default is 3
97+
MaxAttempts int
98+
}
99+
```
100+
101+
### Default Config
102+
103+
```go
104+
var ConfigDefault = Config{
105+
Account: "",
106+
Container: "",
107+
Endpoint: "",
108+
RequestTimeout: 0,
109+
Reset: false,
110+
MaxAttempts: 3,
111+
}
112+
```

0 commit comments

Comments
 (0)