gdaoCache

package
v1.2.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 18, 2024 License: BSD-3-Clause Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
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

func BindMapper(namespace string) error

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

func BindMapperId(namespace, id string) error

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 ClearMapper(namespace, id string) (b bool)

func GetCache

func GetCache(domain, cacheId string, condition *Condition) any

func GetDomain

func GetDomain(classname, tablename string) string

func GetMapperCache

func GetMapperCache(domain, namepace, id string, condition *Condition) any

func GetMapperDomain

func GetMapperDomain(namespace, id string) string

func SetCache

func SetCache(domain string, cacheId string, condition *Condition, value any) bool

func SetMapperCache

func SetMapperCache(domain string, namespace, id string, condition *Condition, value any) bool

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 CacheBean

type CacheBean struct {
	// contains filtered or unexported fields
}

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
}

func NewCondition

func NewCondition(node, sql string, args ...any) *Condition

type SqlKV

type SqlKV struct {
	// contains filtered or unexported fields
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL