diff --git a/bux_suite_test.go b/bux_suite_test.go index 8600775c..2987e086 100644 --- a/bux_suite_test.go +++ b/bux_suite_test.go @@ -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)) @@ -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) diff --git a/bux_test.go b/bux_test.go index d24bdcec..6088f2a9 100644 --- a/bux_test.go +++ b/bux_test.go @@ -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 { diff --git a/client_options.go b/client_options.go index 95cd83e0..74eb7a3a 100644 --- a/client_options.go +++ b/client_options.go @@ -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)) + } } } } diff --git a/client_options_test.go b/client_options_test.go index 42cb2934..e0d5b384 100644 --- a/client_options_test.go +++ b/client_options_test.go @@ -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) { @@ -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) { diff --git a/examples/client/custom_models/custom_models.go b/examples/client/custom_models/custom_models.go index fa2f802c..f65e173e 100644 --- a/examples/client/custom_models/custom_models.go +++ b/examples/client/custom_models/custom_models.go @@ -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 ) diff --git a/examples/client/custom_user_agent/custom_user_agent.go b/examples/client/custom_user_agent/custom_user_agent.go index 890fcb24..0d3d403e 100644 --- a/examples/client/custom_user_agent/custom_user_agent.go +++ b/examples/client/custom_user_agent/custom_user_agent.go @@ -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 ) diff --git a/examples/client/debugging/debugging.go b/examples/client/debugging/debugging.go index f868f530..e0640e2d 100644 --- a/examples/client/debugging/debugging.go +++ b/examples/client/debugging/debugging.go @@ -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) ) diff --git a/examples/client/encryption/encryption.go b/examples/client/encryption/encryption.go index 29311af9..28171f1f 100644 --- a/examples/client/encryption/encryption.go +++ b/examples/client/encryption/encryption.go @@ -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()) diff --git a/examples/client/logging/logging.go b/examples/client/logging/logging.go index 8aa1f566..2599d4a6 100644 --- a/examples/client/logging/logging.go +++ b/examples/client/logging/logging.go @@ -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 ) diff --git a/examples/client/mysql/mysql.go b/examples/client/mysql/mysql.go index 705cbe29..715d1f6a 100644 --- a/examples/client/mysql/mysql.go +++ b/examples/client/mysql/mysql.go @@ -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{ diff --git a/examples/client/new/new.go b/examples/client/new/new.go index 9d6f3f04..ae0b03e5 100644 --- a/examples/client/new/new.go +++ b/examples/client/new/new.go @@ -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 { diff --git a/examples/client/new_relic/new_relic.go b/examples/client/new_relic/new_relic.go index 667f7c13..6df94c8c 100644 --- a/examples/client/new_relic/new_relic.go +++ b/examples/client/new_relic/new_relic.go @@ -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()) diff --git a/examples/client/paymail_support/paymail_support.go b/examples/client/paymail_support/paymail_support.go index 5ebe32f9..64edfedd 100644 --- a/examples/client/paymail_support/paymail_support.go +++ b/examples/client/paymail_support/paymail_support.go @@ -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"},