Skip to content

Commit

Permalink
More examples
Browse files Browse the repository at this point in the history
  • Loading branch information
mrz1836 committed Jul 17, 2019
1 parent 05fc29f commit 855de98
Show file tree
Hide file tree
Showing 2 changed files with 61 additions and 0 deletions.
34 changes: 34 additions & 0 deletions cache_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -603,6 +603,40 @@ func ExampleDestroyCache() {
//Output: cache destroyed
}

// ExampleDelete is an example of Delete() method
func ExampleDelete() {
// Create a local connection
_ = Connect(connectionURL, maxActiveConnections, maxIdleConnections, maxConnLifetime, idleTimeout)

// Disconnect at end
defer Disconnect()

// Set the key/value
_ = Set("example-destroy-cache", "my-value", "another-key")

// Delete keys
_, _ = Delete("another-key", "another-key-2")
fmt.Print("deleted keys")
//Output: deleted keys
}

// ExampleKillByDependency is an example of KillByDependency() method
func ExampleKillByDependency() {
// Create a local connection
_ = Connect(connectionURL, maxActiveConnections, maxIdleConnections, maxConnLifetime, idleTimeout)

// Disconnect at end
defer Disconnect()

// Set the key/value
_ = Set("example-destroy-cache", "my-value", "another-key")

// Delete keys
_, _ = KillByDependency("another-key", "another-key-2")
fmt.Print("deleted keys")
//Output: deleted keys
}

// TestDependencyManagement tests basic dependency functionality
// Tests a myriad of methods
func TestDependencyManagement(t *testing.T) {
Expand Down
27 changes: 27 additions & 0 deletions pool_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,19 @@ func TestConnectToURL(t *testing.T) {
}
}

// ExampleConnectToURL is an example of ConnectToURL() method
func ExampleConnectToURL() {
// Create a local connection
_, _ = ConnectToURL(connectionURL)

// Disconnect at end
defer Disconnect()

// Connected
fmt.Print("connected")
//Output: connected
}

// TestConnect tests the connect method
func TestConnect(t *testing.T) {

Expand Down Expand Up @@ -158,3 +171,17 @@ func ExampleDisconnect() {
fmt.Print("disconnected")
//Output: disconnected
}

// ExampleGetConnection is an example of GetConnection() method
func ExampleGetConnection() {
// Create a local connection
_ = Connect(connectionURL, maxActiveConnections, maxIdleConnections, maxConnLifetime, idleTimeout)

// Disconnect at end
defer Disconnect()

// Connected
_ = GetConnection()
fmt.Print("got connection")
//Output: got connection
}

0 comments on commit 855de98

Please sign in to comment.