Documentation
¶
Index ¶
- type Cache
- func (c *Cache) Clear()
- func (c *Cache) Count() int
- func (c *Cache) Delete(key string)
- func (c *Cache) DeleteSafe(key string) bool
- func (c *Cache) Exists(key string) bool
- func (c *Cache) Get(key string) (any, bool)
- func (c *Cache) GetCrypt(key string) (string, error)
- func (c *Cache) LoadFromBinary(filePathName string) error
- func (c *Cache) Put(key string, value any)
- func (c *Cache) PutCrypt(key, value string) error
- func (c *Cache) PutCryptExp(key, value string, exp int64) error
- func (c *Cache) PutExp(key string, value any, exp int64)
- func (c *Cache) PutSafe(key string, value any) bool
- func (c *Cache) PutSafeExp(key string, value any, exp int64) bool
- func (c *Cache) SaveToBinaryFile(filePathName string) error
- func (c *Cache) SetupPersistToS3(interval int, filePath string)
- type CacheItem
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Cache ¶
type Cache struct {
// contains filtered or unexported fields
}
This is the main cache object
func New ¶
Creates a new cache exp -> The time, in seconds that you want default expiration, 0 is never expire ctx -> The context you want to provide for purposes of telemetry
func NewFromS3 ¶
Creates a new cache from a file in S3 exp -> The time, in seconds that you want default expiration, 0 is never expire cacheKey -> The key you use in your S3 store that we'll pull from - DO NOT include the .godistcache extension ctx -> The context you want to provide for purposes of telemetry
func (*Cache) DeleteSafe ¶
Delete an item from the cache with a check for safety, will return true if successful key -> The key to lookup in the cache
func (*Cache) Exists ¶
Tells you whether or not the item corresponding to the key exists key -> The key to lookup in the cache
func (*Cache) Get ¶
Attempt to get an item from the cache. Will return the item and a bool to indicate success key -> The key to lookup in the cache
func (*Cache) GetCrypt ¶
Attempt to get encrypted value from the cache. Will return the item and an error if unsuccessful key -> The key to lookup in the cache
func (*Cache) LoadFromBinary ¶
This will load any .godistcache file into your cache filePathName -> The path with the filename - DO NOT add the extension .godistcache IMPORTANT -> Make sure to register all your structs with Gob before loading
func (*Cache) Put ¶
Attempt to add an item to the cache key -> The key to lookup in the cache value -> The value to store in the cache
func (*Cache) PutCrypt ¶
Put an encrypted string in the cache key -> The key to lookup in the cache value -> The value to store in the cache
func (*Cache) PutCryptExp ¶
Put an encrypted string in the cache with custom expiration key -> The key to lookup in the cache value -> The value to store in the cache exp -> The expiration delay from now, in seconds
func (*Cache) PutExp ¶
Attempt to add an item with a manual expiration offset (in seconds) key -> The key to lookup in the cache value -> The value to store in the cache
func (*Cache) PutSafe ¶
Add an item to the cache and send confirmation if successful, computationally more expensive (~10%) key -> The key to lookup in the cache value -> The value to store in the cache
func (*Cache) PutSafeExp ¶
Add an item to the cache with custom expiration and send confirmation if successful. Computationally more expensive (~10%) key -> The key to lookup in the cache value -> The value to store in the cache exp -> The expiration delay from now, in seconds
func (*Cache) SaveToBinaryFile ¶
This will convert the cache to a binary and save it to a file IMPORTANT -> Make sure to register all your structs with Gob before saving fileNamePath -> The path with the filename - DO NOT add the extension .godistcache
func (*Cache) SetupPersistToS3 ¶
This will set up a goroutine on the interval you select Interval - In seconds filePath -> The path to store the temporary file, the name comes from the ENV Variable GODISTCACHE_S3_OBJECT