Cache Administration with the Go Client
|
Tip
|
The source code for this tutorial is available on GitHub. |
This tutorial demonstrates how to create and manage caches programmatically using the Go Hot Rod client administration API.
Prerequisites
-
A running Infinispan server.
-
Go 1.25 or later.
Running the Example
go run ./cache-admin
Code Walkthrough
Creating a Simple Cache
Use CreateCache to create a cache with default settings.
This method fails if the cache already exists.
admin.CreateCache(ctx, "SimpleCache", "")
Creating a Cache with XML Configuration
Use GetOrCreateCache with an XML configuration string to create a cache with specific settings such as locking, transactions, and expiration.
admin.GetOrCreateCache(ctx, "CacheWithXMLConfiguration", xmlConfig)
Removing Caches
Use RemoveCache to delete a cache and all its data.
admin.RemoveCache(ctx, "SimpleCache")
Expected Output
SimpleCache created.
Cache with XML configuration exists or is created.
Caches removed.


