Documentation ¶
Index ¶
- Constants
- func BindClass[T gdaoStruct.TableClass]()
- func BindClassWithCacheHandle[T gdaoStruct.TableClass](cacheHandle *CacheHandle)
- func BindExpireWriteClass[T gdaoStruct.TableClass]()
- func BindExpireWriteClassWithCacheHandle[T gdaoStruct.TableClass](cacheHandle *CacheHandle)
- func BindMapper(namespace string) error
- func BindMapperId(namespace, id string) error
- func BindMapperIdWithCacheHandle(namespace, id string, cacheHandle *CacheHandle) error
- func BindMapperWithCacheHandle(namespace string, cacheHandle *CacheHandle) error
- func BindTableNames(tableNames ...string)
- func BindTableNamesWithCacheHandle(cacheHandle *CacheHandle, tableNames ...string)
- func ClearClass[T gdaoStruct.TableClass]() (r bool)
- func ClearExpireWrite[T any]()
- func ClearMapper(namespace, id string) (b bool)
- func GetCache(domain, cacheId string, condition *Condition) any
- func GetDomain(classname, tablename string) string
- func GetMapperCache(domain, namepace, id string, condition *Condition) any
- func GetMapperDomain(namespace, id string) string
- func SetCache(domain string, cacheId string, condition *Condition, value any) bool
- func SetMapperCache(domain string, namespace, id string, condition *Condition, value any) bool
- func UnbindClass[T gdaoStruct.TableClass]()
- func UnbindMapper(namespace string)
- func UnbindMapperId(namespace, id string)
- func UnbindTableNames(tableNames ...string)
- type CacheBean
- type CacheHandle
- type Condition
- type SqlKV
Constants ¶
const ( STRONG storeMode = 1 SOFT storeMode = 2 )
Variables ¶
This section is empty.
Functions ¶
func BindClass ¶
func BindClass[T gdaoStruct.TableClass]()
func BindClassWithCacheHandle ¶
func BindClassWithCacheHandle[T gdaoStruct.TableClass](cacheHandle *CacheHandle)
func BindExpireWriteClass ¶ added in v1.2.2
func BindExpireWriteClass[T gdaoStruct.TableClass]()
BindExpireWriteClass When the data of the bound table is changed, that is, when the operation is deleted, update, or inserted, the cache data is cleared
func BindExpireWriteClassWithCacheHandle ¶ added in v1.2.2
func BindExpireWriteClassWithCacheHandle[T gdaoStruct.TableClass](cacheHandle *CacheHandle)
BindExpireWriteClassWithCacheHandle When the data of the bound table is changed, that is, when the operation is deleted, update, or inserted, the cache data is cleared
func BindMapper ¶
BindMapper binds the specified XML mapping namespace to use the gdao caching mechanism for all query operations.
Parameters:
namespace: The namespace in the XML mapping files that corresponds to the CRUD operations to bind.
Returns:
An error if the binding fails, nil otherwise.
Description:
This function sets up the specified XML mapping namespace to use a caching mechanism for all query operations.
Example:
// Assuming "com.example.mappers.users" is the namespace in the XML mapping files gdaoCache.BindMapper("com.example.mappers.users")
func BindMapperId ¶
BindMapperId binds a specific CRUD operation within the specified XML mapping namespace to use the gdao cache mechanism for query operations.
Parameters:
namespace: The namespace in the XML mapping files that corresponds to the CRUD operations to bind. id: The ID of the CRUD operation within the namespace.
Returns:
An error if the binding fails, nil otherwise.
Description:
This function sets up a specific CRUD operation within the specified XML mapping namespace to use the gdao cache mechanism for query operations.
Example:
// Assuming "com.example.mappers.users" is the namespace in the XML mapping files // And "getUserById" is the ID of the CRUD operation within the namespace err := gdaoCache.BindMapperId("com.example.mappers.users", "getUserById") if err != nil { log.Fatalf("Failed to bind the 'getUserById' query operation with the gdao cache mechanism: %v", err) }
func BindMapperIdWithCacheHandle ¶
func BindMapperIdWithCacheHandle(namespace, id string, cacheHandle *CacheHandle) error
BindMapperIdWithCacheHandle binds a specific CRUD operation within the specified XML mapping namespace to use the given cache handle for query operations.
Parameters:
namespace: The namespace in the XML mapping files that corresponds to the CRUD operations to bind. id: The ID of the CRUD operation within the namespace. cacheHandle: The cache handle that manages the caching mechanism, including cache timeouts and eviction policies.
Returns:
An error if the binding fails, nil otherwise.
Description:
This function sets up a specific CRUD operation within the specified XML mapping namespace to use the provided cache handle for query operations.
Example:
// Assuming "com.example.mappers.users" is the namespace in the XML mapping files // And "getUserById" is the ID of the CRUD operation within the namespace err := gdaoCache.BindMapperIdWithCacheHandle("com.example.mappers.users", "getUserById", gdaoCache.NewCacheHandle().SetExpire(10000)) if err != nil { log.Fatalf("Failed to bind the 'getUserById' qurey operation with the specified cache handle: %v", err) }
func BindMapperWithCacheHandle ¶
func BindMapperWithCacheHandle(namespace string, cacheHandle *CacheHandle) error
BindMapperWithCacheHandle binds the specified XML mapping namespace to use the given cache handle for all query operations.
Parameters:
namespace: The namespace in the XML mapping files that corresponds to the CRUD operations to bind. cacheHandle: The cache handle that manages the caching mechanism, including cache timeouts and eviction policies.
Returns:
An error if the binding fails, nil otherwise.
Description:
This function sets up the specified XML mapping namespace to use the provided cache handle for all query operations.
Example:
// Assuming "com.example.mappers.users" is the namespace in the XML mapping files err := gdaoCache.BindMapperWithCacheHandle("com.example.mappers.users", gdaoCache.NewCacheHandle().SetExpire(10000)) if err != nil { log.Fatalf("Failed to bind the 'com.example.mappers.users' namespace with the specified cache handle: %v", err) }
func BindTableNames ¶
func BindTableNames(tableNames ...string)
BindTableNames binds one or more table names to enable the gdao caching mechanism for data operations on these tables. Parameters:
tableNames: A variadic list of strings representing the names of the tables to bind.
The function configures the caching system to recognize and cache data operations for the specified tables.
func BindTableNamesWithCacheHandle ¶
func BindTableNamesWithCacheHandle(cacheHandle *CacheHandle, tableNames ...string)
BindTableNamesWithCacheHandle binds one or more table names with a CacheHandle to enable the gdao caching mechanism for data operations on these tables. This function is useful when you want to enable caching for specific tables in your application with custom cache settings. Parameters:
cacheHandle: A pointer to a CacheHandle object that defines the caching behavior such as expiration time and eviction policies. tableNames: A variadic list of strings representing the names of the tables to bind.
The function configures the caching system to recognize and cache data operations for the specified tables with the provided cache settings.
func ClearClass ¶ added in v1.1.1
func ClearClass[T gdaoStruct.TableClass]() (r bool)
func ClearExpireWrite ¶ added in v1.2.2
func ClearExpireWrite[T any]()
func ClearMapper ¶ added in v1.1.1
func GetMapperCache ¶
func GetMapperDomain ¶
func SetMapperCache ¶
func UnbindClass ¶
func UnbindClass[T gdaoStruct.TableClass]()
func UnbindMapper ¶
func UnbindMapper(namespace string)
func UnbindMapperId ¶
func UnbindMapperId(namespace, id string)
func UnbindTableNames ¶
func UnbindTableNames(tableNames ...string)
Types ¶
type CacheHandle ¶
type CacheHandle struct {
// contains filtered or unexported fields
}
func NewCacheHandle ¶
func NewCacheHandle() *CacheHandle
func NewCacheHandle2 ¶
func NewCacheHandle2(expire int64, mode storeMode) *CacheHandle
func (*CacheHandle) SetDomain ¶
func (c *CacheHandle) SetDomain(domain string) *CacheHandle
SetDomain set the domain of cacheHandle
func (*CacheHandle) SetExpire ¶
func (c *CacheHandle) SetExpire(expire int64) *CacheHandle
SetExpire set the data validity period in milliseconds.The default is 300*1000
func (*CacheHandle) SetStoreMode ¶
func (c *CacheHandle) SetStoreMode(mode storeMode) *CacheHandle
SetStoreMode set the storage mode. The default is SOFT
type Condition ¶
type Condition struct {
// contains filtered or unexported fields
}