Skip to content

Commit 2c773eb

Browse files
1 parent ca3e390 commit 2c773eb

File tree

5 files changed

+192
-6
lines changed

5 files changed

+192
-6
lines changed

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,5 +69,6 @@ type Storage interface {
6969
- [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>
7070
- [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>
7171
- [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>
72+
- [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>
7273
- [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>
7374

storage_versioned_docs/version-redis_v3.x.x/memory/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ func (s *Storage) Delete(key string) error
3131
func (s *Storage) Reset() error
3232
func (s *Storage) Close() error
3333
func (s *Storage) Conn() map[string]entry
34+
func (s *Storage) Keys() ([][]byte, error)
3435
```
3536

3637
### Installation

storage_versioned_docs/version-redis_v3.x.x/redis/README.md

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ func (s *Storage) Delete(key string) error
2929
func (s *Storage) Reset() error
3030
func (s *Storage) Close() error
3131
func (s *Storage) Conn() redis.UniversalClient
32+
func (s *Storage) Keys() ([][]byte, error)
3233
```
3334
### Installation
3435
Redis 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:
@@ -86,15 +87,15 @@ tlsCfg := &tls.Config{
8687
Certificates: []tls.Certificate{cer},
8788
}
8889
store = redis.New(redis.Config{
89-
URL: "redis://<user>:<pass>@127.0.0.1:6379/<db>",
90+
URL: "redis://<user>:<pass>@127.0.0.1:6379/<db>",
9091
TLSConfig: tlsCfg,
91-
Reset: false,
92+
Reset: false,
9293
})
9394

9495
// Create a client with a Redis URL with all information.
9596
store = redis.New(redis.Config{
96-
URL: "redis://<user>:<pass>@127.0.0.1:6379/<db>",
97-
Reset: false,
97+
URL: "redis://<user>:<pass>@127.0.0.1:6379/<db>",
98+
Reset: false,
9899
})
99100
```
100101

storage_versioned_docs/version-redis_v3.x.x/rueidis/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ type Config struct {
183183

184184
// CacheTTL TTL
185185
//
186-
// Optional. Default is time.Second
186+
// Optional. Default is time.Minute
187187
CacheTTL time.Duration
188188
}
189189
```
@@ -207,6 +207,6 @@ var ConfigDefault = Config{
207207
DisableCache: false,
208208
AlwaysPipelining: true,
209209
Reset: false,
210-
CacheTTL: time.Second,
210+
CacheTTL: time.Minute,
211211
}
212212
```
Lines changed: 183 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,183 @@
1+
---
2+
id: scylladb
3+
title: ScyllaDb
4+
---
5+
6+
![Release](https://img.shields.io/github/v/tag/gofiber/storage?filter=scylladb*)
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-scylladb.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+
# ScyllaDb
13+
14+
A ScyllaDb storage engine for [Fiber](github.com/gofiber/fiber) using [gocql](github.com/scylladb/gocql).
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, value []byte, expire 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() *gocql.Session
32+
```
33+
34+
### Installation
35+
ScyllaDb 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:
36+
```bash
37+
go mod init github.com/<user>/<repo>
38+
```
39+
And then install the scylladb implementation:
40+
```bash
41+
go get github.com/gofiber/storage/scylladb
42+
```
43+
44+
### Examples
45+
Import the storage package.
46+
```go
47+
import "github.com/gofiber/storage/scylladb"
48+
```
49+
50+
You can use the following possibilities to create a storage:
51+
```go
52+
// Initialize default config
53+
store := scylladb.New()
54+
55+
// Initialize custom config
56+
store := scylladb.New(scylladb.Config{
57+
Keyspace: "fiber",
58+
Hosts: []string{"127.0.0.1"},
59+
Port: 9042,
60+
Table: "fiber_storage",
61+
Consistency: "ONE",
62+
Reset: false,
63+
})
64+
65+
// Initialize with support for TLS (SslOptions configures TLS use)
66+
//
67+
// InsecureSkipVerify and EnableHostVerification interact as follows:
68+
//
69+
// |Config.InsecureSkipVerify | EnableHostVerification | Result |
70+
// |--------------------------|------------------------|--------------------|
71+
// |Config is nil | false | do not verify host |
72+
// |Config is nil | true | verify host |
73+
// |false | false | verify host |
74+
// |true | false | do not verify host |
75+
// |false | true | verify host |
76+
// |true | true | verify host |
77+
store := New(
78+
Config{
79+
Keyspace: "fiber",
80+
Hosts: []string{"127.0.0.1"},
81+
Port: 9042,
82+
Table: "fiber_storage",
83+
Consistency: "ONE",
84+
SslOpts: &gocql.SslOptions{
85+
Config: &tls.Config{
86+
InsecureSkipVerify: false, // Set this too false to enable certificate verification
87+
},
88+
CertPath: "/path/to/client_cert.pem", // Path to the client certificate
89+
KeyPath: "/path/to/client_key.pem", // Path to the client certificate's private key
90+
CaPath: "/path/to/ca_cert.pem", // Path to the CA certificate
91+
EnableHostVerification: true, // Enable hostname verification
92+
},
93+
Reset: false,
94+
},
95+
)
96+
97+
// Initialize custom config using scylladb connection
98+
cluster, _ := gocql.NewCluster("127.0.0.1")
99+
cluster.Keyspace = "fiber"
100+
cluster.Port = 9042
101+
102+
session, _ := cluster.CreateSession()
103+
store := scylladb.New(scylladb.Config{
104+
Session: session,
105+
Keyspace: "fiber",
106+
Table: "fiber_storage",
107+
Reset: false,
108+
})
109+
```
110+
111+
### Config
112+
```go
113+
type Config struct {
114+
// Session is provided by the user to use an existing ScyllaDb session
115+
// Session Will override Keyspace and all other authentication values if used
116+
//
117+
// Optional. Default is nil
118+
Session *gocql.Session
119+
120+
// Keyspace name
121+
//
122+
// Optional. Default is "fiber"
123+
Keyspace string
124+
125+
// Hosts are an array of network addresses for establishing initial connections
126+
// You have the flexibility to specify one or multiple addresses as needed
127+
//
128+
// Optional. Default is "127.0.0.1"
129+
Hosts []string
130+
131+
// Port where the ScyllaDb cluster is listening on
132+
//
133+
// Optional. Default is 9042
134+
Port int
135+
136+
// Username for ScyllaDb cluster
137+
//
138+
// Optional. Default is ""
139+
Username string
140+
141+
// Password for ScyllaDb cluster
142+
//
143+
// Optional. Default is ""
144+
Password string
145+
146+
// Table name
147+
//
148+
// Optional. Default is "fiber_storage"
149+
Table string
150+
151+
// Level of the consistency
152+
//
153+
// Optional. Default is "LOCAL_ONE"
154+
Consistency string
155+
156+
// SslOpts configures TLS use.
157+
//
158+
// Optional. Default is nil
159+
SslOpts *gocql.SslOptions
160+
161+
// Reset clears any existing keys in existing Table
162+
//
163+
// Optional. Default is false
164+
Reset bool
165+
}
166+
```
167+
168+
### Default Config
169+
```go
170+
// ConfigDefault is the default config
171+
var ConfigDefault = Config{
172+
Session: nil,
173+
Keyspace: "fiber",
174+
Hosts: []string{"127.0.0.1"},
175+
Username: "",
176+
Password: "",
177+
Port: 9042,
178+
Table: "fiber_storage",
179+
Consistency: "LOCAL_ONE",
180+
SslOpts: nil,
181+
Reset: false,
182+
}
183+
```

0 commit comments

Comments
 (0)