diff --git a/README.md b/README.md
index 4291cf5d..d71f89e2 100644
--- a/README.md
+++ b/README.md
@@ -57,6 +57,9 @@ type Storage interface {
* [Badger](/badger)
+* [Bbolt](/bbolt)
+
+
* [DynamoDB](/dynamodb)
@@ -83,7 +86,4 @@ type Storage interface {
* [S3](/s3)
-
-* [Bbolt](/bbolt)
-
\ No newline at end of file
diff --git a/arangodb/README.md b/arangodb/README.md
index 39509466..7e91ceb6 100644
--- a/arangodb/README.md
+++ b/arangodb/README.md
@@ -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) 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:
diff --git a/arangodb/arangodb.go b/arangodb/arangodb.go
index 12d27521..a7858e9d 100644
--- a/arangodb/arangodb.go
+++ b/arangodb/arangodb.go
@@ -246,3 +246,8 @@ func (s *Storage) gc() {
}
}
}
+
+// Return database client
+func (s *Storage) Conn() driver.Client {
+ return s.client
+}
diff --git a/arangodb/arangodb_test.go b/arangodb/arangodb_test.go
index 7a182789..b8e0bd5d 100644
--- a/arangodb/arangodb_test.go
+++ b/arangodb/arangodb_test.go
@@ -132,3 +132,7 @@ func Test_ARANGODB_Non_UTF8(t *testing.T) {
func Test_ARANGODB_Close(t *testing.T) {
utils.AssertEqual(t, nil, testStore.Close())
}
+
+func Test_ARANGODB_Conn(t *testing.T) {
+ utils.AssertEqual(t, true, testStore.Conn() != nil)
+}
diff --git a/badger/README.md b/badger/README.md
index f494710c..cd40a98e 100644
--- a/badger/README.md
+++ b/badger/README.md
@@ -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) Reset() error
func (s *Storage) Close() error
+func (s *Storage) Conn() *badger.DB
```
### Installation
diff --git a/badger/badger.go b/badger/badger.go
index cf8280e2..0bba2311 100644
--- a/badger/badger.go
+++ b/badger/badger.go
@@ -123,3 +123,8 @@ func (s *Storage) gc() {
}
}
}
+
+// Return database client
+func (s *Storage) Conn() *badger.DB {
+ return s.db
+}
diff --git a/badger/badger_test.go b/badger/badger_test.go
index ce863763..4d04cd9b 100644
--- a/badger/badger_test.go
+++ b/badger/badger_test.go
@@ -119,3 +119,7 @@ func Test_Badger_Reset(t *testing.T) {
func Test_Badger_Close(t *testing.T) {
utils.AssertEqual(t, nil, testStore.Close())
}
+
+func Test_Badger_Conn(t *testing.T) {
+ utils.AssertEqual(t, true, testStore.Conn() != nil)
+}
\ No newline at end of file
diff --git a/bbolt/README.md b/bbolt/README.md
index b3fadc4c..63988417 100644
--- a/bbolt/README.md
+++ b/bbolt/README.md
@@ -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) Reset() error
func (s *Storage) Close() error
+func (s *Storage) Conn() *bbolt.DB
```
### 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:
diff --git a/bbolt/bbolt.go b/bbolt/bbolt.go
index b93253eb..e7509e10 100644
--- a/bbolt/bbolt.go
+++ b/bbolt/bbolt.go
@@ -104,3 +104,8 @@ func (s *Storage) Reset() error {
func (s *Storage) Close() error {
return s.conn.Close()
}
+
+// Return database client
+func (s *Storage) Conn() *bbolt.DB {
+ return s.conn
+}
diff --git a/bbolt/bbolt_test.go b/bbolt/bbolt_test.go
index f703a93a..d9a5456e 100644
--- a/bbolt/bbolt_test.go
+++ b/bbolt/bbolt_test.go
@@ -95,3 +95,7 @@ func Test_Bbolt_Reset(t *testing.T) {
func Test_Bbolt_Close(t *testing.T) {
utils.AssertEqual(t, nil, testStore.Close())
}
+
+func Test_Bbolt_Conn(t *testing.T) {
+ utils.AssertEqual(t, true, testStore.Conn() != nil)
+}
diff --git a/dynamodb/README.md b/dynamodb/README.md
index a7ee9b75..35779e4d 100644
--- a/dynamodb/README.md
+++ b/dynamodb/README.md
@@ -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) Reset() error
func (s *Storage) Close() error
+func (s *Storage) Conn() *awsdynamodb.Client
```
### Installation
diff --git a/dynamodb/dynamodb.go b/dynamodb/dynamodb.go
index fa25bb71..b87a4888 100644
--- a/dynamodb/dynamodb.go
+++ b/dynamodb/dynamodb.go
@@ -264,3 +264,8 @@ func returnAWSConfig(cfg Config) (aws.Config, error) {
}),
)
}
+
+// Return database client
+func (s *Storage) Conn() *awsdynamodb.Client {
+ return s.db
+}
diff --git a/dynamodb/dynamodb_test.go b/dynamodb/dynamodb_test.go
index d70278a2..0cb95574 100644
--- a/dynamodb/dynamodb_test.go
+++ b/dynamodb/dynamodb_test.go
@@ -105,3 +105,7 @@ func Test_DynamoDB_Reset(t *testing.T) {
func Test_DynamoDB_Close(t *testing.T) {
utils.AssertEqual(t, nil, testStore.Close())
}
+
+func Test_DynamoDB_Conn(t *testing.T) {
+ utils.AssertEqual(t, true, testStore.Conn() != nil)
+}
diff --git a/memcache/README.md b/memcache/README.md
index 49e366f5..126551e1 100644
--- a/memcache/README.md
+++ b/memcache/README.md
@@ -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) Reset() error
func (s *Storage) Close() error
+func (s *Storage) Conn() *mc.Client
```
### Installation
diff --git a/memcache/memcache.go b/memcache/memcache.go
index b0245c19..3919da12 100644
--- a/memcache/memcache.go
+++ b/memcache/memcache.go
@@ -122,3 +122,8 @@ func (s *Storage) releaseItem(item *mc.Item) {
s.items.Put(item)
}
}
+
+// Return database client
+func (s *Storage) Conn() *mc.Client {
+ return s.db
+}
diff --git a/memcache/memcache_test.go b/memcache/memcache_test.go
index 52c03cab..75d39981 100644
--- a/memcache/memcache_test.go
+++ b/memcache/memcache_test.go
@@ -119,3 +119,7 @@ func Test_Memcache_Reset(t *testing.T) {
func Test_Memcache_Close(t *testing.T) {
utils.AssertEqual(t, nil, testStore.Close())
}
+
+func Test_Memcache_Conn(t *testing.T) {
+ utils.AssertEqual(t, true, testStore.Conn() != nil)
+}
diff --git a/memory/README.md b/memory/README.md
index 76122fe4..26931cb3 100644
--- a/memory/README.md
+++ b/memory/README.md
@@ -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) Reset() error
func (s *Storage) Close() error
+func (s *Storage) Conn() map[string]entry
```
### Installation
diff --git a/memory/memory.go b/memory/memory.go
index 3282254d..05d6b391 100644
--- a/memory/memory.go
+++ b/memory/memory.go
@@ -116,3 +116,8 @@ func (s *Storage) gc() {
}
}
}
+
+// Return database client
+func (s *Storage) Conn() map[string]entry {
+ return s.db
+}
diff --git a/memory/memory_test.go b/memory/memory_test.go
index 9804836f..2e9a08ef 100644
--- a/memory/memory_test.go
+++ b/memory/memory_test.go
@@ -119,3 +119,7 @@ func Test_Memory_Reset(t *testing.T) {
func Test_Memory_Close(t *testing.T) {
utils.AssertEqual(t, nil, testStore.Close())
}
+
+func Test_Memory_Conn(t *testing.T) {
+ utils.AssertEqual(t, true, testStore.Conn() != nil)
+}
\ No newline at end of file
diff --git a/mongodb/README.md b/mongodb/README.md
index 5322bb20..0a0cf213 100644
--- a/mongodb/README.md
+++ b/mongodb/README.md
@@ -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) Reset() error
func (s *Storage) Close() error
+func (s *Storage) Conn() *mongo.Database
```
### 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:
diff --git a/mongodb/mongodb.go b/mongodb/mongodb.go
index b33c9974..a94adb19 100644
--- a/mongodb/mongodb.go
+++ b/mongodb/mongodb.go
@@ -199,3 +199,8 @@ func (s *Storage) releaseItem(item *item) {
s.items.Put(item)
}
}
+
+// Return database client
+func (s *Storage) Conn() *mongo.Database {
+ return s.db
+}
diff --git a/mongodb/mongodb_test.go b/mongodb/mongodb_test.go
index de42bbc3..2b39b68d 100644
--- a/mongodb/mongodb_test.go
+++ b/mongodb/mongodb_test.go
@@ -121,3 +121,7 @@ func Test_MongoDB_Reset(t *testing.T) {
func Test_MongoDB_Close(t *testing.T) {
utils.AssertEqual(t, nil, testStore.Close())
}
+
+func Test_MongoDB_Conn(t *testing.T) {
+ utils.AssertEqual(t, true, testStore.Conn() != nil)
+}
diff --git a/mysql/README.md b/mysql/README.md
index dc15f5a7..9a07f59e 100644
--- a/mysql/README.md
+++ b/mysql/README.md
@@ -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) Reset() error
func (s *Storage) Close() error
+func (s *Storage) Conn() *sql.DB
```
### 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:
diff --git a/mysql/mysql.go b/mysql/mysql.go
index cdde2846..35b8879b 100644
--- a/mysql/mysql.go
+++ b/mysql/mysql.go
@@ -165,6 +165,11 @@ func (s *Storage) Close() error {
return s.db.Close()
}
+// Return database client
+func (s *Storage) Conn() *sql.DB {
+ return s.db
+}
+
// gcTicker starts the gc ticker
func (s *Storage) gcTicker() {
ticker := time.NewTicker(s.gcInterval)
diff --git a/mysql/mysql_test.go b/mysql/mysql_test.go
index d5897c08..733fda8d 100644
--- a/mysql/mysql_test.go
+++ b/mysql/mysql_test.go
@@ -162,3 +162,7 @@ func Test_MYSQL_Non_UTF8(t *testing.T) {
func Test_MYSQL_Close(t *testing.T) {
utils.AssertEqual(t, nil, testStore.Close())
}
+
+func Test_MYSQL_Conn(t *testing.T) {
+ utils.AssertEqual(t, true, testStore.Conn() != nil)
+}
diff --git a/postgres/README.md b/postgres/README.md
index 03342cd9..60ea5101 100644
--- a/postgres/README.md
+++ b/postgres/README.md
@@ -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) Reset() error
func (s *Storage) Close() error
+func (s *Storage) Conn() *sql.DB
```
### 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:
diff --git a/postgres/postgres.go b/postgres/postgres.go
index fabfe196..2e2dc816 100644
--- a/postgres/postgres.go
+++ b/postgres/postgres.go
@@ -189,6 +189,11 @@ func (s *Storage) Close() error {
return s.db.Close()
}
+// Return database client
+func (s *Storage) Conn() *sql.DB {
+ return s.db
+}
+
// gcTicker starts the gc ticker
func (s *Storage) gcTicker() {
ticker := time.NewTicker(s.gcInterval)
diff --git a/postgres/postgres_test.go b/postgres/postgres_test.go
index 062b235f..c2af76bd 100644
--- a/postgres/postgres_test.go
+++ b/postgres/postgres_test.go
@@ -177,3 +177,7 @@ func Test_SslRequiredMode(t *testing.T) {
func Test_Postgres_Close(t *testing.T) {
utils.AssertEqual(t, nil, testStore.Close())
}
+
+func Test_Postgres_Conn(t *testing.T) {
+ utils.AssertEqual(t, true, testStore.Conn() != nil)
+}
diff --git a/redis/README.md b/redis/README.md
index 16f12bbc..161a028e 100644
--- a/redis/README.md
+++ b/redis/README.md
@@ -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) Reset() error
func (s *Storage) Close() error
+func (s *Storage) Conn() *redis.Client
```
### 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:
@@ -86,11 +87,11 @@ type Config struct {
// Optional. Default is 0
Database int
- // URL the standard format redis url to parse all other options. If this is set all other config options, Host, Port, Username, Password, Database have no effect.
- //
- // Example: redis://:@localhost:6379/
- // Optional. Default is ""
- URL string
+ // URL the standard format redis url to parse all other options. If this is set all other config options, Host, Port, Username, Password, Database have no effect.
+ //
+ // Example: redis://:@localhost:6379/
+ // Optional. Default is ""
+ URL string
// Reset clears any existing keys in existing Collection
//
diff --git a/redis/redis.go b/redis/redis.go
index 599fd3b2..4f2f6ea0 100644
--- a/redis/redis.go
+++ b/redis/redis.go
@@ -99,3 +99,8 @@ func (s *Storage) Reset() error {
func (s *Storage) Close() error {
return s.db.Close()
}
+
+// Return database client
+func (s *Storage) Conn() *redis.Client {
+ return s.db
+}
diff --git a/redis/redis_test.go b/redis/redis_test.go
index ada0f8e6..567d4ea6 100644
--- a/redis/redis_test.go
+++ b/redis/redis_test.go
@@ -123,6 +123,10 @@ func Test_Redis_Close(t *testing.T) {
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) {
testStoreUrl := New(Config{
URL: "redis://localhost:6379",
diff --git a/ristretto/README.md b/ristretto/README.md
index d1540386..96ee2fba 100644
--- a/ristretto/README.md
+++ b/ristretto/README.md
@@ -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) Reset() error
func (s *Storage) Close() error
+func (s *Storage) Conn() *ristretto.Cache
```
### Installation
diff --git a/ristretto/ristretto.go b/ristretto/ristretto.go
index 3233c0ef..36a7ccd5 100644
--- a/ristretto/ristretto.go
+++ b/ristretto/ristretto.go
@@ -89,3 +89,8 @@ func (s *Storage) Close() error {
s.cache.Close()
return nil
}
+
+// Return database client
+func (s *Storage) Conn() *ristretto.Cache {
+ return s.cache
+}
diff --git a/ristretto/ristretto_test.go b/ristretto/ristretto_test.go
index b424273b..0fbf6b14 100644
--- a/ristretto/ristretto_test.go
+++ b/ristretto/ristretto_test.go
@@ -126,3 +126,7 @@ func Test_Ristretto_Reset(t *testing.T) {
func Test_Ristretto_Close(t *testing.T) {
utils.AssertEqual(t, nil, testStore.Close())
}
+
+func Test_Ristretto_Conn(t *testing.T) {
+ utils.AssertEqual(t, true, testStore.Conn() != nil)
+}
diff --git a/s3/README.md b/s3/README.md
index 78bce204..f7ca7bee 100644
--- a/s3/README.md
+++ b/s3/README.md
@@ -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) Reset() error
func (s *Storage) Close() error
+func (s *Storage) Conn() *s3.Client
```
### 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:
diff --git a/s3/s3.go b/s3/s3.go
index da328a51..921b02a7 100644
--- a/s3/s3.go
+++ b/s3/s3.go
@@ -159,6 +159,11 @@ func (s *Storage) Close() error {
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
func (s *Storage) requestContext() (context.Context, context.CancelFunc) {
if s.requestTimeout > 0 {
diff --git a/s3/s3_test.go b/s3/s3_test.go
index 7b3f27fe..a62bf0f7 100644
--- a/s3/s3_test.go
+++ b/s3/s3_test.go
@@ -105,3 +105,7 @@ func Test_S3_Reset(t *testing.T) {
func Test_S3_Close(t *testing.T) {
utils.AssertEqual(t, nil, testStore.Close())
}
+
+func Test_S3_Conn(t *testing.T) {
+ utils.AssertEqual(t, true, testStore.Conn() != nil)
+}
diff --git a/sqlite3/README.md b/sqlite3/README.md
index 35d40bd7..4c2f1eb7 100644
--- a/sqlite3/README.md
+++ b/sqlite3/README.md
@@ -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) Reset() error
func (s *Storage) Close() error
+func (s *Storage) Conn() *sql.DB
```
### 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:
diff --git a/sqlite3/sqlite3.go b/sqlite3/sqlite3.go
index 0f1f7961..7070a3b8 100644
--- a/sqlite3/sqlite3.go
+++ b/sqlite3/sqlite3.go
@@ -169,3 +169,8 @@ func (s *Storage) gcTicker() {
func (s *Storage) gc(t time.Time) {
_, _ = s.db.Exec(s.sqlGC, t.Unix())
}
+
+// Return database client
+func (s *Storage) Conn() *sql.DB {
+ return s.db
+}
diff --git a/sqlite3/sqlite3_test.go b/sqlite3/sqlite3_test.go
index 1f51e96b..312bd234 100644
--- a/sqlite3/sqlite3_test.go
+++ b/sqlite3/sqlite3_test.go
@@ -159,3 +159,7 @@ func Test_SQLite3_Non_UTF8(t *testing.T) {
func Test_SQLite3_Close(t *testing.T) {
utils.AssertEqual(t, nil, testStore.Close())
}
+
+func Test_SQLite3_Conn(t *testing.T) {
+ utils.AssertEqual(t, true, testStore.Conn() != nil)
+}
\ No newline at end of file