Skip to content
This repository has been archived by the owner on Apr 2, 2024. It is now read-only.

Commit

Permalink
Default cache engine is FreeCache
Browse files Browse the repository at this point in the history
  • Loading branch information
mrz1836 committed Apr 6, 2022
1 parent cef3a4a commit 06b1e34
Show file tree
Hide file tree
Showing 13 changed files with 20 additions and 23 deletions.
2 changes: 0 additions & 2 deletions bux_suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -320,7 +320,6 @@ func (ts *EmbeddedDBTestSuite) genericDBClient(t *testing.T, database datastore.
WithDebugging(),
WithAutoMigrate(BaseModels...),
WithAutoMigrate(&PaymailAddress{}),
WithFreeCache(),
)
if taskManagerEnabled {
opts = append(opts, WithTaskQ(taskmanager.DefaultTaskQConfig(prefix+"_queue"), taskmanager.FactoryMemory))
Expand Down Expand Up @@ -353,7 +352,6 @@ func (ts *EmbeddedDBTestSuite) genericMockedDBClient(t *testing.T, database data
database, prefix,
true, true, WithDebugging(),
WithCustomTaskManager(&taskManagerMockBase{}),
WithFreeCache(),
)
require.NoError(t, err)
require.NotNil(t, tc)
Expand Down
1 change: 0 additions & 1 deletion bux_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,6 @@ func DefaultClientOpts(debug, shared bool) []ClientOps {
opts = append(
opts,
WithTaskQ(tqc, taskmanager.FactoryMemory),
WithFreeCache(),
WithSQLite(tester.SQLiteTestConfig(debug, shared)),
)
if debug {
Expand Down
3 changes: 3 additions & 0 deletions client_options.go
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,9 @@ func WithLogger(customLogger logger.Interface) ClientOps {
if c.dataStore != nil {
c.dataStore.options = append(c.dataStore.options, datastore.WithLogger(c.logger))
}
if c.cacheStore != nil {
c.cacheStore.options = append(c.cacheStore.options, cachestore.WithLogger(c.logger))
}
}
}
}
Expand Down
12 changes: 9 additions & 3 deletions client_options_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,7 @@ func TestWithFreeCache(t *testing.T) {
}

// TestWithFreeCacheConnection will test the method WithFreeCacheConnection()
func TestWithMcacheConnection(t *testing.T) {
func TestWithFreeCacheConnection(t *testing.T) {
t.Parallel()

t.Run("using a nil client", func(t *testing.T) {
Expand All @@ -269,8 +269,14 @@ func TestWithMcacheConnection(t *testing.T) {
WithFreeCacheConnection(nil),
WithTaskQ(taskmanager.DefaultTaskQConfig(testQueueName), taskmanager.FactoryMemory),
WithSQLite(&datastore.SQLiteConfig{Shared: true}))
require.Error(t, err)
require.Nil(t, tc)
require.NoError(t, err)
require.NotNil(t, tc)

defer CloseClient(context.Background(), t, tc)

cs := tc.Cachestore()
require.NotNil(t, cs)
assert.Equal(t, cachestore.FreeCache, cs.Engine())
})

t.Run("using an existing connection", func(t *testing.T) {
Expand Down
3 changes: 1 addition & 2 deletions examples/client/custom_models/custom_models.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,7 @@ import (

func main() {
client, err := bux.NewClient(
context.Background(), // Set context
bux.WithFreeCache(), // Cache
context.Background(), // Set context
bux.WithTaskQ(taskmanager.DefaultTaskQConfig("test_queue"), taskmanager.FactoryMemory), // Tasks
bux.WithModels(NewExample("example-field")), // Add additional custom models to Bux
)
Expand Down
3 changes: 1 addition & 2 deletions examples/client/custom_user_agent/custom_user_agent.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,7 @@ import (

func main() {
client, err := bux.NewClient(
context.Background(), // Set context
bux.WithFreeCache(), // Cache
context.Background(), // Set context
bux.WithTaskQ(taskmanager.DefaultTaskQConfig("test_queue"), taskmanager.FactoryMemory), // Tasks
bux.WithUserAgent("my-custom-user-agent"), // Custom user agent
)
Expand Down
1 change: 0 additions & 1 deletion examples/client/debugging/debugging.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import (
func main() {
client, err := bux.NewClient(
context.Background(), // Set context
bux.WithFreeCache(), // Cache
bux.WithTaskQ(taskmanager.DefaultTaskQConfig("test_queue"), taskmanager.FactoryMemory), // Tasks
bux.WithDebugging(), // Enable debugging (verbose logs)
)
Expand Down
7 changes: 3 additions & 4 deletions examples/client/encryption/encryption.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,10 @@ import (

func main() {
client, err := bux.NewClient(
context.Background(), // Set context
bux.WithFreeCache(), // Cache
context.Background(), // Set context
bux.WithTaskQ(taskmanager.DefaultTaskQConfig("test_queue"), taskmanager.FactoryMemory), // Tasks
bux.WithDebugging(), // Enable debugging (verbose logs)
bux.WithEncryption(os.Getenv("BUX_ENCRYPTION_KEY")), // Encryption key for external public keys (paymail)
bux.WithDebugging(), // Enable debugging (verbose logs)
bux.WithEncryption(os.Getenv("BUX_ENCRYPTION_KEY")), // Encryption key for external public keys (paymail)
)
if err != nil {
log.Fatalln("error: " + err.Error())
Expand Down
3 changes: 1 addition & 2 deletions examples/client/logging/logging.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@ import (

func main() {
client, err := bux.NewClient(
context.Background(), // Set context
bux.WithFreeCache(), // Cache
context.Background(), // Set context
bux.WithTaskQ(taskmanager.DefaultTaskQConfig("test_queue"), taskmanager.FactoryMemory), // Tasks
bux.WithLogger(logger.NewLogger(false)), // Example of using a custom logger
)
Expand Down
1 change: 0 additions & 1 deletion examples/client/mysql/mysql.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ func main() {
TxTimeout: defaultTimeouts,
User: os.Getenv("DB_USER"),
}),
bux.WithFreeCache(), // Cache
bux.WithTaskQ(taskmanager.DefaultTaskQConfig("test_queue"), taskmanager.FactoryMemory), // Tasks
bux.WithAutoMigrate( // All models
append(bux.BaseModels, &bux.PaymailAddress{
Expand Down
3 changes: 1 addition & 2 deletions examples/client/new/new.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,7 @@ import (

func main() {
client, err := bux.NewClient(
context.Background(), // Set context
bux.WithFreeCache(), // Cache
context.Background(), // Set context
bux.WithTaskQ(taskmanager.DefaultTaskQConfig("test_queue"), taskmanager.FactoryMemory), // Tasks
)
if err != nil {
Expand Down
3 changes: 1 addition & 2 deletions examples/client/new_relic/new_relic.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,8 @@ func main() {
var client bux.ClientInterface
client, err = bux.NewClient(
newrelic.NewContext(context.Background(), app.StartTransaction("test-txn")), // Set context
bux.WithFreeCache(), // Cache
bux.WithTaskQ(taskmanager.DefaultTaskQConfig("test_queue"), taskmanager.FactoryMemory), // Tasks
bux.WithNewRelic(app), // New relic application (from your own application or server)
bux.WithNewRelic(app), // New relic application (from your own application or server)
)
if err != nil {
log.Fatalln("error: " + err.Error())
Expand Down
1 change: 0 additions & 1 deletion examples/client/paymail_support/paymail_support.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import (
func main() {
client, err := bux.NewClient(
context.Background(), // Set context
bux.WithFreeCache(), // Cache
bux.WithTaskQ(taskmanager.DefaultTaskQConfig("test_queue"), taskmanager.FactoryMemory), // Tasks
bux.WithPaymailSupport(
[]string{"test.com"},
Expand Down

0 comments on commit 06b1e34

Please sign in to comment.