Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CacheInterface ¶
type CacheInterface interface { Init() error Get(cacheKey string) ([]byte, bool, error) GetConfig() config.Config Set(cacheKey string, item []byte) error GetItemTTL(cacheKey string) (time.Duration, bool, error) ExtendTTL(cacheKey string, item []byte) error }
The above code defines a CacheInterface type in Go that represents a cache with methods for initialization, getting and setting items, and managing item time-to-live (TTL). @property {error} Init - The Init method is used to initialize the cache. It can be used to set up any necessary data structures or connections required for caching. @property Get - The Get method retrieves an item from the cache based on the provided cache key. It returns the item, a boolean indicating whether the item was found in the cache, and an error if any occurred. @property {error} Set - The Set method is used to store an item in the cache. It takes a cacheKey string as the identifier for the item and the item itself as the value to be stored in the cache. @property GetItemTTL - GetItemTTL is a method that retrieves the time-to-live (TTL) value for a specific item in the cache. The TTL represents the amount of time that the item will remain in the cache before it expires and is automatically removed. The method returns the TTL value as a time.Duration, @property {error} ExtendTTL - ExtendTTL is a method that extends the time to live (TTL) of a cached item. It takes a cacheKey string and an item interface as parameters. The cacheKey is used to identify the cached item, and the item is the updated value that will be stored in the cache.
var CacheInstance CacheInterface
The line `var CacheInstance CacheInterface` is declaring a variable named `CacheInstance` of type `CacheInterface`. This variable will be used to store an instance of a cache that implements the `CacheInterface` interface.