-
Notifications
You must be signed in to change notification settings - Fork 138
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Sync docs for release https://github.com/gofiber/storage/releases/tag…
- Loading branch information
1 parent
b4157b7
commit f008f34
Showing
24 changed files
with
2,626 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
--- | ||
title: 👋 Welcome | ||
description: 📦 Premade storage drivers for 🚀 Fiber. | ||
sidebar_position: 1 | ||
--- | ||
|
||
<p align="center"> | ||
<img height="125" alt="Fiber" src="https://raw.githubusercontent.com/gofiber/storage/master/.github/logo-dark.svg#gh-dark-mode-only" /> | ||
<img height="125" alt="Fiber" src="https://raw.githubusercontent.com/gofiber/storage/master/.github/logo.svg#gh-light-mode-only" /> | ||
<br/> | ||
|
||
<a href="https://pkg.go.dev/github.com/gofiber/storage?tab=doc"> | ||
<img src="https://img.shields.io/badge/%F0%9F%93%9A%20godoc-pkg-00ACD7.svg?color=00ACD7&style=flat"/> | ||
</a> | ||
<a href="https://goreportcard.com/report/github.com/gofiber/storage"> | ||
<img src="https://img.shields.io/badge/%F0%9F%93%9D%20goreport-A%2B-75C46B"/> | ||
</a> | ||
<a href="https://gofiber.io/discord"> | ||
<img src="https://img.shields.io/discord/704680098577514527?style=flat&label=%F0%9F%92%AC%20discord&color=00ACD7"/> | ||
</a> | ||
</p> | ||
|
||
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). | ||
|
||
```go | ||
// Storage interface for communicating with different database/key-value | ||
// providers. Visit https://github.com/gofiber/storage for more info. | ||
type Storage interface { | ||
// Get gets the value for the given key. | ||
// `nil, nil` is returned when the key does not exist | ||
Get(key string) ([]byte, error) | ||
|
||
// Set stores the given value for the given key along | ||
// with an expiration value, 0 means no expiration. | ||
// Empty key or value will be ignored without an error. | ||
Set(key string, val []byte, exp time.Duration) error | ||
|
||
// Delete deletes the value for the given key. | ||
// It returns no error if the storage does not contain the key, | ||
Delete(key string) error | ||
|
||
// Reset resets the storage and delete all keys. | ||
Reset() error | ||
|
||
// Close closes the storage and will stop any running garbage | ||
// collectors and open connections. | ||
Close() error | ||
} | ||
``` | ||
|
||
## 📑 Storage Implementations | ||
|
||
- [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> | ||
- [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> | ||
- [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> | ||
- [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> | ||
- [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> | ||
- [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> | ||
- [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> | ||
- [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> | ||
- [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> | ||
- [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> | ||
- [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> | ||
- [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> | ||
- [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> | ||
- [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> | ||
- [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> | ||
- [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> | ||
- [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> | ||
- [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> | ||
- [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> | ||
- [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> | ||
|
120 changes: 120 additions & 0 deletions
120
storage_versioned_docs/version-minio_v0.x.x/arangodb/README.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,120 @@ | ||
--- | ||
id: arangodb | ||
title: ArangoDB | ||
--- | ||
|
||
![Release](https://img.shields.io/github/v/tag/gofiber/storage?filter=arangodb*) | ||
[![Discord](https://img.shields.io/discord/704680098577514527?style=flat&label=%F0%9F%92%AC%20discord&color=00ACD7)](https://gofiber.io/discord) | ||
![Test](https://img.shields.io/github/actions/workflow/status/gofiber/storage/test-arangodb.yml?label=Tests) | ||
![Security](https://img.shields.io/github/actions/workflow/status/gofiber/storage/gosec.yml?label=Security) | ||
![Linter](https://img.shields.io/github/actions/workflow/status/gofiber/storage/linter.yml?label=Linter) | ||
|
||
A ArangoDB storage driver using `arangodb/go-driver` and [arangodb/go-driver](https://github.com/arangodb/go-driver). | ||
|
||
**Note: Requires Go 1.19 and above** | ||
|
||
### Table of Contents | ||
- [Signatures](#signatures) | ||
- [Installation](#installation) | ||
- [Examples](#examples) | ||
- [Config](#config) | ||
- [Default Config](#default-config) | ||
|
||
### Signatures | ||
```go | ||
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 | ||
func (s *Storage) Conn() driver.Client | ||
``` | ||
### Installation | ||
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: | ||
```bash | ||
go mod init github.com/<user>/<repo> | ||
``` | ||
And then install the mysql implementation: | ||
```bash | ||
go get github.com/gofiber/storage/arangodb/v2 | ||
``` | ||
|
||
### Examples | ||
Import the storage package. | ||
```go | ||
import "github.com/gofiber/storage/arangodb/v2" | ||
``` | ||
|
||
You can use the following possibilities to create a storage: | ||
```go | ||
// Initialize default config | ||
store := arangodb.New() | ||
|
||
// Initialize custom config | ||
store := arangodb.New(arangodb.Config{ | ||
Host: "http://127.0.0.1", | ||
Port: 8529, | ||
Database: "fiber", | ||
Collection: "fiber_storage", | ||
Reset: false, | ||
GCInterval: 10 * time.Second, | ||
}) | ||
``` | ||
|
||
### Config | ||
```go | ||
type Config struct { | ||
// Host name where the DB is hosted | ||
// | ||
// Optional. Default is "http://127.0.0.1" | ||
Host string | ||
|
||
// Port where the DB is listening on | ||
// | ||
// Optional. Default is 8529 | ||
Port int | ||
|
||
// Server username | ||
// | ||
// Optional. Default is "" | ||
Username string | ||
|
||
// Server password | ||
// | ||
// Optional. Default is "" | ||
Password string | ||
|
||
// Database name | ||
// | ||
// Optional. Default is "fiber" | ||
Database string | ||
|
||
// Collection name | ||
// | ||
// Optional. Default is "fiber_storage" | ||
Collection string | ||
|
||
// Reset clears any existing keys in existing collection | ||
// | ||
// Optional. Default is false | ||
Reset bool | ||
// Time before deleting expired keys | ||
// | ||
// Optional. Default is 10 * time.Second | ||
GCInterval time.Duration | ||
} | ||
``` | ||
|
||
### Default Config | ||
Used only for optional fields | ||
```go | ||
var ConfigDefault = Config{ | ||
Host: "http://127.0.0.1", | ||
Port: 8529, | ||
Database: "fiber", | ||
Collection: "fiber_storage", | ||
Reset: false, | ||
GCInterval: 10 * time.Second, | ||
} | ||
``` |
112 changes: 112 additions & 0 deletions
112
storage_versioned_docs/version-minio_v0.x.x/azureblob/README.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,112 @@ | ||
--- | ||
id: azureblob | ||
title: Azure Blob | ||
--- | ||
|
||
![Release](https://img.shields.io/github/v/tag/gofiber/storage?filter=azureblob*) | ||
[![Discord](https://img.shields.io/discord/704680098577514527?style=flat&label=%F0%9F%92%AC%20discord&color=00ACD7)](https://gofiber.io/discord) | ||
![Test](https://img.shields.io/github/actions/workflow/status/gofiber/storage/test-azureblob.yml?label=Tests) | ||
![Security](https://img.shields.io/github/actions/workflow/status/gofiber/storage/gosec.yml?label=Security) | ||
![Linter](https://img.shields.io/github/actions/workflow/status/gofiber/storage/linter.yml?label=Linter) | ||
|
||
[Azure Blob storage](https://azure.microsoft.com/en-us/products/storage/blobs/#overview) is Microsoft's object storage solution for the cloud. | ||
|
||
**Note: Requires Go 1.19 and above** | ||
|
||
### Table of Contents | ||
|
||
- [Signatures](#signatures) | ||
- [Installation](#installation) | ||
- [Examples](#examples) | ||
- [Config](#config) | ||
- [Default Config](#default-config) | ||
|
||
### Signatures | ||
|
||
```go | ||
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 | ||
func (s *Storage) Conn() *azblob.Client | ||
``` | ||
|
||
### Installation | ||
|
||
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: | ||
|
||
```bash | ||
go mod init github.com/<user>/<repo> | ||
``` | ||
|
||
And then install the azure blob implementation: | ||
|
||
```bash | ||
go get github.com/gofiber/storage/azureblob/v2 | ||
``` | ||
|
||
### Examples | ||
|
||
Import the storage package. | ||
|
||
```go | ||
import "github.com/gofiber/storage/azureblob/v2" | ||
``` | ||
|
||
You can use the following possibilities to create a storage: | ||
|
||
```go | ||
// Initialize default config | ||
store := azureblob.New() | ||
|
||
// Initialize custom config | ||
store := azureblob.New(azureblob.Config{ | ||
Account: "test", | ||
Container: "test", | ||
Credentials: Credentials{ | ||
Account: "test", | ||
Key: "YXp1cml0ZWtleQo=", | ||
}, | ||
}) | ||
``` | ||
|
||
### Config | ||
|
||
```go | ||
type Config struct { | ||
// Storage account name. | ||
Account string | ||
// Container name. | ||
Container string | ||
// Storage endpoint. | ||
// Optional. Default: "https://STORAGEACCOUNTNAME.blob.core.windows.net" | ||
Endpoint string | ||
// Request timeout. | ||
// Optional. Default is 0 (no timeout) | ||
RequestTimeout time.Duration | ||
// Reset clears any existing keys in existing container. | ||
// Optional. Default is false | ||
Reset bool | ||
// Credentials overrides AWS access key and AWS secret access key. Not recommended. | ||
// Optional. Default is Credentials{} | ||
Credentials Credentials | ||
// The maximum number of times requests that encounter retryable failures should be attempted. | ||
// Optional. Default is 3 | ||
MaxAttempts int | ||
} | ||
``` | ||
|
||
### Default Config | ||
|
||
```go | ||
var ConfigDefault = Config{ | ||
Account: "", | ||
Container: "", | ||
Endpoint: "", | ||
RequestTimeout: 0, | ||
Reset: false, | ||
MaxAttempts: 3, | ||
} | ||
``` |
Oops, something went wrong.