Skip to content

Commit 8e829d7

Browse files
1 parent 9c53833 commit 8e829d7

File tree

8 files changed

+271
-41
lines changed

8 files changed

+271
-41
lines changed

storage_versioned_docs/version-clickhouse_v0.x.x/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,3 +75,4 @@ type Storage interface {
7575
- [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>
7676
- [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>
7777
- [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>
78+
- [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>

storage_versioned_docs/version-clickhouse_v0.x.x/clickhouse/README.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,13 @@ Install the clickhouse implementation:
3131
go get github.com/gofiber/storage/clickhouse
3232
```
3333

34-
Before running or testing this implementation, you must ensure a Clickhouse cluster is available.
34+
### Running the tests
35+
36+
This module uses [Testcontainers for Go](https://github.com/testcontainers/testcontainers-go/) to run integration tests, which will start a local instance of Clickhouse as a Docker container under the hood. To run the tests, you must have Docker (or another container runtime 100% compatible with the Docker APIs) installed on your machine.
37+
38+
### Local development
39+
40+
Before running this implementation, you must ensure a Clickhouse cluster is available.
3541
For local development, we recommend using the Clickhouse Docker image; it contains everything
3642
necessary for the client to operate correctly.
3743

storage_versioned_docs/version-clickhouse_v0.x.x/coherence/README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# Coherence
2-
<!-- Copyright © 2023, Oracle and/or its affiliates. -->
2+
<!-- Copyright © 2023, 2025 Oracle and/or its affiliates. -->
33
A Coherence storage driver using [https://github.com/oracle/coherence-go-client](https://github.com/oracle/coherence-go-client).
44

55
### Table of Contents
@@ -35,10 +35,10 @@ necessary for the client to operate correctly.
3535
To start a Coherence cluster using Docker, issue the following:
3636

3737
```bash
38-
docker run -d -p 1408:1408 ghcr.io/oracle/coherence-ce:22.06.7
38+
docker run -d -p 1408:1408 ghcr.io/oracle/coherence-ce:24.09
3939
```
4040

41-
See the documentation [here](https://pkg.go.dev/github.com/oracle/coherence-go-client/coherence#hdr-Obtaining_a_Session) on connection options
41+
See the documentation [here](https://pkg.go.dev/github.com/oracle/coherence-go-client/[email protected]/coherence#hdr-Obtaining_a_Session) on connection options
4242
when creating a Coherence session.
4343

4444
### Examples

storage_versioned_docs/version-clickhouse_v0.x.x/minio/README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,10 @@ type Config struct {
9494
// Optional. Default is false
9595
Reset bool
9696

97+
// The maximum number of times requests that encounter retryable failures should be attempted.
98+
// Optional. Default is 10, same as the MinIO client.
99+
MaxRetry int
100+
97101
// Credentials Minio access key and Minio secret key.
98102
// Need to be defined
99103
Credentials Credentials
@@ -124,6 +128,7 @@ var ConfigDefault = Config{
124128
Token: "",
125129
Secure: false,
126130
Reset: false,
131+
127132
Credentials: Credentials{},
128133
GetObjectOptions: minio.GetObjectOptions{},
129134
PutObjectOptions: minio.PutObjectOptions{},

storage_versioned_docs/version-clickhouse_v0.x.x/nats/README.md

Lines changed: 31 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ title: Nats
1212

1313
A NATS Key/Value storage driver.
1414

15-
**Note: Requires Go 1.20 and above**
15+
## Note: Requires Go 1.20 and above
1616

1717
### Table of Contents
1818

@@ -57,60 +57,56 @@ Import the storage package.
5757
import "github.com/gofiber/storage/nats"
5858
```
5959

60-
You can use the following possibilities to create a storage:
60+
You can use the following options to create a storage driver:
6161

6262
```go
6363
// Initialize default config
6464
store := nats.New()
6565

6666
// Initialize custom config
6767
store := nats.New(Config{
68-
URLs: "nats://127.0.0.1:4443",
69-
NatsOptions: []nats.Option{
70-
nats.MaxReconnects(2),
71-
// Enable TLS by specifying RootCAs
72-
nats.RootCAs("./testdata/certs/ca.pem"),
73-
},
74-
KeyValueConfig: jetstream.KeyValueConfig{
75-
Bucket: "test",
76-
Storage: jetstream.MemoryStorage,
77-
},
68+
URLs: "nats://127.0.0.1:4443",
69+
NatsOptions: []nats.Option{
70+
nats.MaxReconnects(2),
71+
// Enable TLS by specifying RootCAs
72+
nats.RootCAs("./testdata/certs/ca.pem"),
73+
},
74+
KeyValueConfig: jetstream.KeyValueConfig{
75+
Bucket: "test",
76+
Storage: jetstream.MemoryStorage,
77+
},
7878
})
7979
```
8080

8181
### Config
8282

8383
```go
8484
type Config struct {
85-
// Nats URLs, default "nats://127.0.0.1:4222". Can be comma separated list for multiple servers
86-
URLs string
87-
// Nats connection options. See nats_test.go for an example of how to use this.
88-
NatsOptions []nats.Option
89-
// Nats connection name
90-
ClientName string
91-
// Nats context
92-
Context context.Context
93-
// Nats key value config
94-
KeyValueConfig jetstream.KeyValueConfig
95-
// Logger. Using Fiber AllLogger interface for adapting the various log libraries.
96-
Logger log.AllLogger
97-
// Use the Logger for nats events, default: false
98-
Verbose bool
99-
// Wait for connection to be established, default: 100ms
100-
WaitForConnection time.Duration
85+
// Nats URLs, default "nats://127.0.0.1:4222". Can be comma separated list for multiple servers
86+
URLs string
87+
// Nats connection options. See nats_test.go for an example of how to use this.
88+
NatsOptions []nats.Option
89+
// Nats connection name
90+
ClientName string
91+
// Nats context
92+
Context context.Context
93+
// Nats key value config
94+
KeyValueConfig jetstream.KeyValueConfig
95+
// Wait for connection to be established, default: 100ms
96+
WaitForConnection time.Duration
10197
}
10298
```
10399

104100
### Default Config
105101

106102
```go
107103
var ConfigDefault = Config{
108-
URLs: nats.DefaultURL,
109-
Context: context.Background(),
110-
ClientName: "fiber_storage",
111-
KeyValueConfig: jetstream.KeyValueConfig{
112-
Bucket: "fiber_storage",
113-
},
114-
WaitForConnection: 100 * time.Millisecond,
104+
URLs: nats.DefaultURL,
105+
Context: context.Background(),
106+
ClientName: "fiber_storage",
107+
KeyValueConfig: jetstream.KeyValueConfig{
108+
Bucket: "fiber_storage",
109+
},
110+
WaitForConnection: 100 * time.Millisecond,
115111
}
116112
```

storage_versioned_docs/version-clickhouse_v0.x.x/postgres/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ title: Postgres
1111

1212
A Postgres storage driver using [jackc/pgx](https://github.com/jackc/pgx).
1313

14-
**Note: Requires Go 1.19 and above**
14+
**Note: Requires Go 1.20 and above**
1515

1616
### Table of Contents
1717
- [Signatures](#signatures)
Lines changed: 222 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,222 @@
1+
---
2+
id: valkey
3+
title: Valkey
4+
---
5+
6+
![Release](https://img.shields.io/github/v/tag/gofiber/storage?filter=valkey*)
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-valkey.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 fast Valkey Storage that does auto pipelining and supports client side caching. Implementation is based on [valkey-io/valkey](https://github.com/valkey-io/valkey-go).
13+
14+
### Table of Contents
15+
16+
- [Signatures](#signatures)
17+
- [Installation](#installation)
18+
- [Examples](#examples)
19+
- [Config](#config)
20+
- [Default Config](#default-config)
21+
22+
### Signatures
23+
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() valkey.Client
32+
```
33+
34+
### Installation
35+
36+
The valkey driver is tested on the latest two [Go version](https://golang.org/dl/) with support for modules. So make sure to initialize one first if you didn't do that yet:
37+
38+
```bash
39+
go mod init github.com/<user>/<repo>
40+
```
41+
42+
And then install the valkey implementation:
43+
44+
```bash
45+
go get github.com/gofiber/storage/valkey
46+
```
47+
48+
### Examples
49+
50+
Import the storage package.
51+
52+
```go
53+
import "github.com/gofiber/storage/valkey"
54+
```
55+
56+
You can use the one of the following options to create a Valkey Storage:
57+
58+
```go
59+
// Initialize default config (localhost:6379)
60+
store := valkey.New()
61+
62+
// Initialize custom config
63+
store := valkey.New(valkey.Config{
64+
InitAddress: []string{"localhost:6380"},
65+
Username: "",
66+
Password: "",
67+
Database: 0,
68+
Reset: false,
69+
TLSConfig: nil,
70+
})
71+
72+
// Initialize using Redis-style URL
73+
store := valkey.New(valkey.Config{
74+
URL: "redis://localhost:6379",
75+
})
76+
77+
// Initialize Valkey Cluster Client
78+
store := valkey.New(valkey.Config{
79+
InitAddress: []string{":6379", ":6380"},
80+
})
81+
82+
// Create a client with support for TLS
83+
cer, err := tls.LoadX509KeyPair("./client.crt", "./client.key")
84+
if err != nil {
85+
log.Println(err)
86+
return
87+
}
88+
tlsCfg := &tls.Config{
89+
MinVersion: tls.VersionTLS12,
90+
InsecureSkipVerify: true,
91+
Certificates: []tls.Certificate{cer},
92+
}
93+
store = valkey.New(valkey.Config{
94+
InitAddress: []string{"localhost:6380"},
95+
Username: "<user>",
96+
Password: "<password>",
97+
SelectDB: 0,
98+
TLSConfig: tlsCfg,
99+
})
100+
101+
```
102+
103+
### Config
104+
105+
```go
106+
type Config struct {
107+
// Server username
108+
//
109+
// Optional. Default is ""
110+
Username string
111+
112+
// Server password
113+
//
114+
// Optional. Default is ""
115+
Password string
116+
117+
// ClientName will execute the `CLIENT SETNAME ClientName` command for each conn.
118+
//
119+
// Optional. Default is ""
120+
ClientName string
121+
122+
// URL standard format Redis-style URL. If this is set all other config options, InitAddress, Username, Password, ClientName, and SelectDB have no effect.
123+
//
124+
// Example: redis://<user>:<pass>@localhost:6379/<db>
125+
// Optional. Default is ""
126+
URL string
127+
128+
// SelectDB to be selected after connecting to the server.
129+
//
130+
// Optional. Default is 0
131+
SelectDB int
132+
133+
// Either a single address or a seed list of host:port addresses, this enables FailoverClient and ClusterClient
134+
//
135+
// Optional. Default is []string{"127.0.0.1:6379"}
136+
InitAddress []string
137+
138+
// TLS Config to use. When set TLS will be negotiated.
139+
//
140+
// Optional. Default is nil
141+
TLSConfig *tls.Config
142+
143+
// CacheSizeEachConn is valkey client side cache size that bind to each TCP connection to a single valkey instance.
144+
//
145+
// Optional. The default is DefaultCacheBytes: 128 * (1 << 20)
146+
CacheSizeEachConn int
147+
148+
// RingScaleEachConn sets the size of the ring buffer in each connection to (2 ^ RingScaleEachConn).
149+
//
150+
// Optional. The default is RingScaleEachConn, which results into having a ring of size 2^10 for each connection.
151+
RingScaleEachConn int
152+
153+
// ReadBufferEachConn is the size of the bufio.NewReaderSize for each connection, default to DefaultReadBuffer (0.5 MiB).
154+
//
155+
// Optional. The default is DefaultReadBuffer: 1 << 19
156+
ReadBufferEachConn int
157+
158+
// WriteBufferEachConn is the size of the bufio.NewWriterSize for each connection, default to DefaultWriteBuffer (0.5 MiB).
159+
//
160+
// Optional. The default is DefaultWriteBuffer: 1 << 19
161+
WriteBufferEachConn int
162+
163+
// BlockingPoolSize is the size of the connection pool shared by blocking commands (ex BLPOP, XREAD with BLOCK).
164+
//
165+
// Optional. The default is DefaultPoolSize: 1000
166+
BlockingPoolSize int
167+
168+
// PipelineMultiplex determines how many tcp connections used to pipeline commands to one valkey instance.
169+
//
170+
// Optional. The default for single and sentinel clients is 2, which means 4 connections (2^2).
171+
PipelineMultiplex int
172+
173+
// DisableRetry disables retrying read-only commands under network errors
174+
//
175+
// Optional. The default is False
176+
DisableRetry bool
177+
178+
// DisableCache falls back Client.DoCache/Client.DoMultiCache to Client.Do/Client.DoMulti
179+
//
180+
// Optional. The default is false
181+
DisableCache bool
182+
183+
// AlwaysPipelining makes valkey.Client always pipeline valkey commands even if they are not issued concurrently.
184+
//
185+
// Optional. The default is true
186+
AlwaysPipelining bool
187+
188+
// Reset clears any existing keys in existing Collection
189+
//
190+
// Optional. Default is false
191+
Reset bool
192+
193+
// CacheTTL TTL
194+
//
195+
// Optional. Default is time.Minute
196+
CacheTTL time.Duration
197+
}
198+
```
199+
200+
### Default Config
201+
202+
```go
203+
var ConfigDefault = Config{
204+
Username: "",
205+
Password: "",
206+
ClientName: "",
207+
SelectDB: 0,
208+
InitAddress: []string{"127.0.0.1:6379"},
209+
TLSConfig: nil,
210+
CacheSizeEachConn: valkey.DefaultCacheBytes,
211+
RingScaleEachConn: valkey.DefaultRingScale,
212+
ReadBufferEachConn: valkey.DefaultReadBuffer,
213+
WriteBufferEachConn: valkey.DefaultWriteBuffer,
214+
BlockingPoolSize: valkey.DefaultPoolSize,
215+
PipelineMultiplex: 2,
216+
DisableRetry: false,
217+
DisableCache: false,
218+
AlwaysPipelining: true,
219+
Reset: false,
220+
CacheTTL: time.Minute,
221+
}
222+
```

storage_versioned_sidebars/version-clickhouse_v0.x.x-sidebars.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"tutorialSidebar": [
2+
"left_sidebar": [
33
{
44
"type": "autogenerated",
55
"dirName": "."

0 commit comments

Comments
 (0)