mirror of
https://github.com/gofiber/storage.git
synced 2025-10-05 00:33:03 +08:00
Add Conn() support to all storage drivers. (#451)
* Add DB() support for Redis driver * Added support for DB() to all drivers * Fixed typo in README and Lint issue * Fix lint issue with ristretto db * Fix lint issue with bbolt db * Rename DB() to Conn() * Replace all instances of _DB with _Conn * Update all the README files * Return ArangoDB Client instead of DB
This commit is contained in:

committed by
GitHub

parent
c38c925975
commit
3a8b8d4f71
@@ -57,6 +57,9 @@ type Storage interface {
|
|||||||
* [Badger](/badger) <a href="https://github.com/gofiber/storage/actions?query=workflow%3A%22Local+Storage%22">
|
* [Badger](/badger) <a href="https://github.com/gofiber/storage/actions?query=workflow%3A%22Local+Storage%22">
|
||||||
<img src="https://img.shields.io/github/workflow/status/gofiber/storage/Local%20Storage?label=%F0%9F%A7%AA%20&style=flat&color=75C46B">
|
<img src="https://img.shields.io/github/workflow/status/gofiber/storage/Local%20Storage?label=%F0%9F%A7%AA%20&style=flat&color=75C46B">
|
||||||
</a>
|
</a>
|
||||||
|
* [Bbolt](/bbolt) <a href="https://github.com/gofiber/storage/actions?query=workflow%3A%22Bbolt%22">
|
||||||
|
<img src="https://img.shields.io/github/workflow/status/gofiber/storage/Bbolt?label=%F0%9F%A7%AA%20&style=flat&color=75C46B">
|
||||||
|
</a>
|
||||||
* [DynamoDB](/dynamodb) <a href="https://github.com/gofiber/storage/actions?query=workflow%3A%22DynamoDB%22">
|
* [DynamoDB](/dynamodb) <a href="https://github.com/gofiber/storage/actions?query=workflow%3A%22DynamoDB%22">
|
||||||
<img src="https://img.shields.io/github/workflow/status/gofiber/storage/DynamoDB?label=%F0%9F%A7%AA%20&style=flat&color=75C46B">
|
<img src="https://img.shields.io/github/workflow/status/gofiber/storage/DynamoDB?label=%F0%9F%A7%AA%20&style=flat&color=75C46B">
|
||||||
</a>
|
</a>
|
||||||
@@ -84,6 +87,3 @@ type Storage interface {
|
|||||||
* [S3](/s3) <a href="https://github.com/gofiber/storage/actions?query=workflow%3A%22S3%22">
|
* [S3](/s3) <a href="https://github.com/gofiber/storage/actions?query=workflow%3A%22S3%22">
|
||||||
<img src="https://img.shields.io/github/workflow/status/gofiber/storage/S3?label=%F0%9F%A7%AA%20&style=flat&color=75C46B">
|
<img src="https://img.shields.io/github/workflow/status/gofiber/storage/S3?label=%F0%9F%A7%AA%20&style=flat&color=75C46B">
|
||||||
</a>
|
</a>
|
||||||
* [Bbolt](/bbolt) <a href="https://github.com/gofiber/storage/actions?query=workflow%3A%22Bbolt%22">
|
|
||||||
<img src="https://img.shields.io/github/workflow/status/gofiber/storage/Bbolt?label=%F0%9F%A7%AA%20&style=flat&color=75C46B">
|
|
||||||
</a>
|
|
@@ -16,6 +16,7 @@ func (s *Storage) Set(key string, val []byte, exp time.Duration) error
|
|||||||
func (s *Storage) Delete(key string) error
|
func (s *Storage) Delete(key string) error
|
||||||
func (s *Storage) Reset() error
|
func (s *Storage) Reset() error
|
||||||
func (s *Storage) Close() error
|
func (s *Storage) Close() error
|
||||||
|
func (s *Storage) Conn() driver.Client
|
||||||
```
|
```
|
||||||
### Installation
|
### 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:
|
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:
|
||||||
|
@@ -246,3 +246,8 @@ func (s *Storage) gc() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Return database client
|
||||||
|
func (s *Storage) Conn() driver.Client {
|
||||||
|
return s.client
|
||||||
|
}
|
||||||
|
@@ -132,3 +132,7 @@ func Test_ARANGODB_Non_UTF8(t *testing.T) {
|
|||||||
func Test_ARANGODB_Close(t *testing.T) {
|
func Test_ARANGODB_Close(t *testing.T) {
|
||||||
utils.AssertEqual(t, nil, testStore.Close())
|
utils.AssertEqual(t, nil, testStore.Close())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func Test_ARANGODB_Conn(t *testing.T) {
|
||||||
|
utils.AssertEqual(t, true, testStore.Conn() != nil)
|
||||||
|
}
|
||||||
|
@@ -19,6 +19,7 @@ func (s *Storage) Set(key string, val []byte, exp time.Duration) error
|
|||||||
func (s *Storage) Delete(key string) error
|
func (s *Storage) Delete(key string) error
|
||||||
func (s *Storage) Reset() error
|
func (s *Storage) Reset() error
|
||||||
func (s *Storage) Close() error
|
func (s *Storage) Close() error
|
||||||
|
func (s *Storage) Conn() *badger.DB
|
||||||
```
|
```
|
||||||
|
|
||||||
### Installation
|
### Installation
|
||||||
|
@@ -123,3 +123,8 @@ func (s *Storage) gc() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Return database client
|
||||||
|
func (s *Storage) Conn() *badger.DB {
|
||||||
|
return s.db
|
||||||
|
}
|
||||||
|
@@ -119,3 +119,7 @@ func Test_Badger_Reset(t *testing.T) {
|
|||||||
func Test_Badger_Close(t *testing.T) {
|
func Test_Badger_Close(t *testing.T) {
|
||||||
utils.AssertEqual(t, nil, testStore.Close())
|
utils.AssertEqual(t, nil, testStore.Close())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func Test_Badger_Conn(t *testing.T) {
|
||||||
|
utils.AssertEqual(t, true, testStore.Conn() != nil)
|
||||||
|
}
|
@@ -17,6 +17,7 @@ func (s *Storage) Set(key string, val []byte, exp time.Duration) error
|
|||||||
func (s *Storage) Delete(key string) error
|
func (s *Storage) Delete(key string) error
|
||||||
func (s *Storage) Reset() error
|
func (s *Storage) Reset() error
|
||||||
func (s *Storage) Close() error
|
func (s *Storage) Close() error
|
||||||
|
func (s *Storage) Conn() *bbolt.DB
|
||||||
```
|
```
|
||||||
### Installation
|
### Installation
|
||||||
Bbolt 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:
|
Bbolt 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:
|
||||||
|
@@ -104,3 +104,8 @@ func (s *Storage) Reset() error {
|
|||||||
func (s *Storage) Close() error {
|
func (s *Storage) Close() error {
|
||||||
return s.conn.Close()
|
return s.conn.Close()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Return database client
|
||||||
|
func (s *Storage) Conn() *bbolt.DB {
|
||||||
|
return s.conn
|
||||||
|
}
|
||||||
|
@@ -95,3 +95,7 @@ func Test_Bbolt_Reset(t *testing.T) {
|
|||||||
func Test_Bbolt_Close(t *testing.T) {
|
func Test_Bbolt_Close(t *testing.T) {
|
||||||
utils.AssertEqual(t, nil, testStore.Close())
|
utils.AssertEqual(t, nil, testStore.Close())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func Test_Bbolt_Conn(t *testing.T) {
|
||||||
|
utils.AssertEqual(t, true, testStore.Conn() != nil)
|
||||||
|
}
|
||||||
|
@@ -23,6 +23,7 @@ func (s *Storage) Set(key string, val []byte, exp time.Duration) error
|
|||||||
func (s *Storage) Delete(key string) error
|
func (s *Storage) Delete(key string) error
|
||||||
func (s *Storage) Reset() error
|
func (s *Storage) Reset() error
|
||||||
func (s *Storage) Close() error
|
func (s *Storage) Close() error
|
||||||
|
func (s *Storage) Conn() *awsdynamodb.Client
|
||||||
```
|
```
|
||||||
|
|
||||||
### Installation
|
### Installation
|
||||||
|
@@ -264,3 +264,8 @@ func returnAWSConfig(cfg Config) (aws.Config, error) {
|
|||||||
}),
|
}),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Return database client
|
||||||
|
func (s *Storage) Conn() *awsdynamodb.Client {
|
||||||
|
return s.db
|
||||||
|
}
|
||||||
|
@@ -105,3 +105,7 @@ func Test_DynamoDB_Reset(t *testing.T) {
|
|||||||
func Test_DynamoDB_Close(t *testing.T) {
|
func Test_DynamoDB_Close(t *testing.T) {
|
||||||
utils.AssertEqual(t, nil, testStore.Close())
|
utils.AssertEqual(t, nil, testStore.Close())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func Test_DynamoDB_Conn(t *testing.T) {
|
||||||
|
utils.AssertEqual(t, true, testStore.Conn() != nil)
|
||||||
|
}
|
||||||
|
@@ -17,6 +17,7 @@ func (s *Storage) Set(key string, val []byte, exp time.Duration) error
|
|||||||
func (s *Storage) Delete(key string) error
|
func (s *Storage) Delete(key string) error
|
||||||
func (s *Storage) Reset() error
|
func (s *Storage) Reset() error
|
||||||
func (s *Storage) Close() error
|
func (s *Storage) Close() error
|
||||||
|
func (s *Storage) Conn() *mc.Client
|
||||||
```
|
```
|
||||||
|
|
||||||
### Installation
|
### Installation
|
||||||
|
@@ -122,3 +122,8 @@ func (s *Storage) releaseItem(item *mc.Item) {
|
|||||||
s.items.Put(item)
|
s.items.Put(item)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Return database client
|
||||||
|
func (s *Storage) Conn() *mc.Client {
|
||||||
|
return s.db
|
||||||
|
}
|
||||||
|
@@ -119,3 +119,7 @@ func Test_Memcache_Reset(t *testing.T) {
|
|||||||
func Test_Memcache_Close(t *testing.T) {
|
func Test_Memcache_Close(t *testing.T) {
|
||||||
utils.AssertEqual(t, nil, testStore.Close())
|
utils.AssertEqual(t, nil, testStore.Close())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func Test_Memcache_Conn(t *testing.T) {
|
||||||
|
utils.AssertEqual(t, true, testStore.Conn() != nil)
|
||||||
|
}
|
||||||
|
@@ -18,6 +18,7 @@ func (s *Storage) Set(key string, val []byte, exp time.Duration) error
|
|||||||
func (s *Storage) Delete(key string) error
|
func (s *Storage) Delete(key string) error
|
||||||
func (s *Storage) Reset() error
|
func (s *Storage) Reset() error
|
||||||
func (s *Storage) Close() error
|
func (s *Storage) Close() error
|
||||||
|
func (s *Storage) Conn() map[string]entry
|
||||||
```
|
```
|
||||||
|
|
||||||
### Installation
|
### Installation
|
||||||
|
@@ -116,3 +116,8 @@ func (s *Storage) gc() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Return database client
|
||||||
|
func (s *Storage) Conn() map[string]entry {
|
||||||
|
return s.db
|
||||||
|
}
|
||||||
|
@@ -119,3 +119,7 @@ func Test_Memory_Reset(t *testing.T) {
|
|||||||
func Test_Memory_Close(t *testing.T) {
|
func Test_Memory_Close(t *testing.T) {
|
||||||
utils.AssertEqual(t, nil, testStore.Close())
|
utils.AssertEqual(t, nil, testStore.Close())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func Test_Memory_Conn(t *testing.T) {
|
||||||
|
utils.AssertEqual(t, true, testStore.Conn() != nil)
|
||||||
|
}
|
@@ -17,6 +17,7 @@ func (s *Storage) Set(key string, val []byte, exp time.Duration) error
|
|||||||
func (s *Storage) Delete(key string) error
|
func (s *Storage) Delete(key string) error
|
||||||
func (s *Storage) Reset() error
|
func (s *Storage) Reset() error
|
||||||
func (s *Storage) Close() error
|
func (s *Storage) Close() error
|
||||||
|
func (s *Storage) Conn() *mongo.Database
|
||||||
```
|
```
|
||||||
### Installation
|
### Installation
|
||||||
MongoDB 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:
|
MongoDB 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:
|
||||||
|
@@ -199,3 +199,8 @@ func (s *Storage) releaseItem(item *item) {
|
|||||||
s.items.Put(item)
|
s.items.Put(item)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Return database client
|
||||||
|
func (s *Storage) Conn() *mongo.Database {
|
||||||
|
return s.db
|
||||||
|
}
|
||||||
|
@@ -121,3 +121,7 @@ func Test_MongoDB_Reset(t *testing.T) {
|
|||||||
func Test_MongoDB_Close(t *testing.T) {
|
func Test_MongoDB_Close(t *testing.T) {
|
||||||
utils.AssertEqual(t, nil, testStore.Close())
|
utils.AssertEqual(t, nil, testStore.Close())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func Test_MongoDB_Conn(t *testing.T) {
|
||||||
|
utils.AssertEqual(t, true, testStore.Conn() != nil)
|
||||||
|
}
|
||||||
|
@@ -17,6 +17,7 @@ func (s *Storage) Set(key string, val []byte, exp time.Duration) error
|
|||||||
func (s *Storage) Delete(key string) error
|
func (s *Storage) Delete(key string) error
|
||||||
func (s *Storage) Reset() error
|
func (s *Storage) Reset() error
|
||||||
func (s *Storage) Close() error
|
func (s *Storage) Close() error
|
||||||
|
func (s *Storage) Conn() *sql.DB
|
||||||
```
|
```
|
||||||
### Installation
|
### Installation
|
||||||
MySQL 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:
|
MySQL 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:
|
||||||
|
@@ -165,6 +165,11 @@ func (s *Storage) Close() error {
|
|||||||
return s.db.Close()
|
return s.db.Close()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Return database client
|
||||||
|
func (s *Storage) Conn() *sql.DB {
|
||||||
|
return s.db
|
||||||
|
}
|
||||||
|
|
||||||
// gcTicker starts the gc ticker
|
// gcTicker starts the gc ticker
|
||||||
func (s *Storage) gcTicker() {
|
func (s *Storage) gcTicker() {
|
||||||
ticker := time.NewTicker(s.gcInterval)
|
ticker := time.NewTicker(s.gcInterval)
|
||||||
|
@@ -162,3 +162,7 @@ func Test_MYSQL_Non_UTF8(t *testing.T) {
|
|||||||
func Test_MYSQL_Close(t *testing.T) {
|
func Test_MYSQL_Close(t *testing.T) {
|
||||||
utils.AssertEqual(t, nil, testStore.Close())
|
utils.AssertEqual(t, nil, testStore.Close())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func Test_MYSQL_Conn(t *testing.T) {
|
||||||
|
utils.AssertEqual(t, true, testStore.Conn() != nil)
|
||||||
|
}
|
||||||
|
@@ -17,6 +17,7 @@ func (s *Storage) Set(key string, val []byte, exp time.Duration) error
|
|||||||
func (s *Storage) Delete(key string) error
|
func (s *Storage) Delete(key string) error
|
||||||
func (s *Storage) Reset() error
|
func (s *Storage) Reset() error
|
||||||
func (s *Storage) Close() error
|
func (s *Storage) Close() error
|
||||||
|
func (s *Storage) Conn() *sql.DB
|
||||||
```
|
```
|
||||||
### Installation
|
### Installation
|
||||||
Postgres 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:
|
Postgres 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:
|
||||||
|
@@ -189,6 +189,11 @@ func (s *Storage) Close() error {
|
|||||||
return s.db.Close()
|
return s.db.Close()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Return database client
|
||||||
|
func (s *Storage) Conn() *sql.DB {
|
||||||
|
return s.db
|
||||||
|
}
|
||||||
|
|
||||||
// gcTicker starts the gc ticker
|
// gcTicker starts the gc ticker
|
||||||
func (s *Storage) gcTicker() {
|
func (s *Storage) gcTicker() {
|
||||||
ticker := time.NewTicker(s.gcInterval)
|
ticker := time.NewTicker(s.gcInterval)
|
||||||
|
@@ -177,3 +177,7 @@ func Test_SslRequiredMode(t *testing.T) {
|
|||||||
func Test_Postgres_Close(t *testing.T) {
|
func Test_Postgres_Close(t *testing.T) {
|
||||||
utils.AssertEqual(t, nil, testStore.Close())
|
utils.AssertEqual(t, nil, testStore.Close())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func Test_Postgres_Conn(t *testing.T) {
|
||||||
|
utils.AssertEqual(t, true, testStore.Conn() != nil)
|
||||||
|
}
|
||||||
|
@@ -17,6 +17,7 @@ func (s *Storage) Set(key string, val []byte, exp time.Duration) error
|
|||||||
func (s *Storage) Delete(key string) error
|
func (s *Storage) Delete(key string) error
|
||||||
func (s *Storage) Reset() error
|
func (s *Storage) Reset() error
|
||||||
func (s *Storage) Close() error
|
func (s *Storage) Close() error
|
||||||
|
func (s *Storage) Conn() *redis.Client
|
||||||
```
|
```
|
||||||
### Installation
|
### Installation
|
||||||
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:
|
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:
|
||||||
|
@@ -99,3 +99,8 @@ func (s *Storage) Reset() error {
|
|||||||
func (s *Storage) Close() error {
|
func (s *Storage) Close() error {
|
||||||
return s.db.Close()
|
return s.db.Close()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Return database client
|
||||||
|
func (s *Storage) Conn() *redis.Client {
|
||||||
|
return s.db
|
||||||
|
}
|
||||||
|
@@ -123,6 +123,10 @@ func Test_Redis_Close(t *testing.T) {
|
|||||||
utils.AssertEqual(t, nil, testStore.Close())
|
utils.AssertEqual(t, nil, testStore.Close())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func Test_Redis_Conn(t *testing.T) {
|
||||||
|
utils.AssertEqual(t, true, testStore.Conn() != nil)
|
||||||
|
}
|
||||||
|
|
||||||
func Test_Redis_Initalize_WithURL(t *testing.T) {
|
func Test_Redis_Initalize_WithURL(t *testing.T) {
|
||||||
testStoreUrl := New(Config{
|
testStoreUrl := New(Config{
|
||||||
URL: "redis://localhost:6379",
|
URL: "redis://localhost:6379",
|
||||||
|
@@ -18,6 +18,7 @@ func (s *Storage) Set(key string, val []byte, exp time.Duration) error
|
|||||||
func (s *Storage) Delete(key string) error
|
func (s *Storage) Delete(key string) error
|
||||||
func (s *Storage) Reset() error
|
func (s *Storage) Reset() error
|
||||||
func (s *Storage) Close() error
|
func (s *Storage) Close() error
|
||||||
|
func (s *Storage) Conn() *ristretto.Cache
|
||||||
```
|
```
|
||||||
|
|
||||||
### Installation
|
### Installation
|
||||||
|
@@ -89,3 +89,8 @@ func (s *Storage) Close() error {
|
|||||||
s.cache.Close()
|
s.cache.Close()
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Return database client
|
||||||
|
func (s *Storage) Conn() *ristretto.Cache {
|
||||||
|
return s.cache
|
||||||
|
}
|
||||||
|
@@ -126,3 +126,7 @@ func Test_Ristretto_Reset(t *testing.T) {
|
|||||||
func Test_Ristretto_Close(t *testing.T) {
|
func Test_Ristretto_Close(t *testing.T) {
|
||||||
utils.AssertEqual(t, nil, testStore.Close())
|
utils.AssertEqual(t, nil, testStore.Close())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func Test_Ristretto_Conn(t *testing.T) {
|
||||||
|
utils.AssertEqual(t, true, testStore.Conn() != nil)
|
||||||
|
}
|
||||||
|
@@ -20,6 +20,7 @@ func (s *Storage) Set(key string, val []byte, exp time.Duration) error
|
|||||||
func (s *Storage) Delete(key string) error
|
func (s *Storage) Delete(key string) error
|
||||||
func (s *Storage) Reset() error
|
func (s *Storage) Reset() error
|
||||||
func (s *Storage) Close() error
|
func (s *Storage) Close() error
|
||||||
|
func (s *Storage) Conn() *s3.Client
|
||||||
```
|
```
|
||||||
### Installation
|
### Installation
|
||||||
S3 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:
|
S3 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:
|
||||||
|
5
s3/s3.go
5
s3/s3.go
@@ -159,6 +159,11 @@ func (s *Storage) Close() error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Return database client
|
||||||
|
func (s *Storage) Conn() *s3.Client {
|
||||||
|
return s.svc
|
||||||
|
}
|
||||||
|
|
||||||
// Context for making requests will timeout if a non-zero timeout is configured
|
// Context for making requests will timeout if a non-zero timeout is configured
|
||||||
func (s *Storage) requestContext() (context.Context, context.CancelFunc) {
|
func (s *Storage) requestContext() (context.Context, context.CancelFunc) {
|
||||||
if s.requestTimeout > 0 {
|
if s.requestTimeout > 0 {
|
||||||
|
@@ -105,3 +105,7 @@ func Test_S3_Reset(t *testing.T) {
|
|||||||
func Test_S3_Close(t *testing.T) {
|
func Test_S3_Close(t *testing.T) {
|
||||||
utils.AssertEqual(t, nil, testStore.Close())
|
utils.AssertEqual(t, nil, testStore.Close())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func Test_S3_Conn(t *testing.T) {
|
||||||
|
utils.AssertEqual(t, true, testStore.Conn() != nil)
|
||||||
|
}
|
||||||
|
@@ -17,6 +17,7 @@ func (s *Storage) Set(key string, val []byte, exp time.Duration) error
|
|||||||
func (s *Storage) Delete(key string) error
|
func (s *Storage) Delete(key string) error
|
||||||
func (s *Storage) Reset() error
|
func (s *Storage) Reset() error
|
||||||
func (s *Storage) Close() error
|
func (s *Storage) Close() error
|
||||||
|
func (s *Storage) Conn() *sql.DB
|
||||||
```
|
```
|
||||||
### Installation
|
### Installation
|
||||||
SQLite3 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:
|
SQLite3 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:
|
||||||
|
@@ -169,3 +169,8 @@ func (s *Storage) gcTicker() {
|
|||||||
func (s *Storage) gc(t time.Time) {
|
func (s *Storage) gc(t time.Time) {
|
||||||
_, _ = s.db.Exec(s.sqlGC, t.Unix())
|
_, _ = s.db.Exec(s.sqlGC, t.Unix())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Return database client
|
||||||
|
func (s *Storage) Conn() *sql.DB {
|
||||||
|
return s.db
|
||||||
|
}
|
||||||
|
@@ -159,3 +159,7 @@ func Test_SQLite3_Non_UTF8(t *testing.T) {
|
|||||||
func Test_SQLite3_Close(t *testing.T) {
|
func Test_SQLite3_Close(t *testing.T) {
|
||||||
utils.AssertEqual(t, nil, testStore.Close())
|
utils.AssertEqual(t, nil, testStore.Close())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func Test_SQLite3_Conn(t *testing.T) {
|
||||||
|
utils.AssertEqual(t, true, testStore.Conn() != nil)
|
||||||
|
}
|
Reference in New Issue
Block a user