Documentation
¶
Index ¶
- func GenerateKey(s ...string) string
- func ReadExtraTTL(filename string) error
- type APICacheKey
- type Cache
- func (c *Cache) CacheFunc(apikey APICacheKey, key string, f func() ([]byte, error)) ([]byte, bool, error)
- func (c *Cache) CacheFuncJSON(apikey APICacheKey, key string, f func() (interface{}, error)) ([]byte, bool, error)
- func (c *Cache) Close() error
- func (c *Cache) Delete(apikey APICacheKey, key string) (bool, error)
- func (c *Cache) DeleteMany(key []string) (int64, error)
- func (c *Cache) Insert(apikey APICacheKey, key string, value []byte) (bool, error)
- func (c *Cache) Len() (int64, error)
- func (c *Cache) Ping(timeout time.Duration) error
- func (c *Cache) Select(apikey APICacheKey, key string) ([]byte, error)
- type CacheDriver
- type ExpirationMachine
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GenerateKey ¶
func ReadExtraTTL ¶
Types ¶
type APICacheKey ¶
var ( EMPTY_APIKEY APICacheKey = APICacheKey{Key: "", ExtraTTL: 0} ADVANCED_SEARCH APICacheKey = APICacheKey{ Key: "0", ExtraTTL: 0, } COMPETITION_STANDING_TABLE APICacheKey = APICacheKey{ Key: "1", ExtraTTL: 0, } COMPETITION_WEEKS APICacheKey = APICacheKey{ Key: "2", ExtraTTL: 0, } COMPETITIONS_LIST APICacheKey = APICacheKey{ Key: "3", ExtraTTL: 0, } MATCH_INFO APICacheKey = APICacheKey{ Key: "4", ExtraTTL: 0, } MATCHES_BY_DATE APICacheKey = APICacheKey{ Key: "5", ExtraTTL: 0, } MATCHES_BY_WEEKNUMBER APICacheKey = APICacheKey{ Key: "6", ExtraTTL: 0, } TRANSFERS APICacheKey = APICacheKey{ Key: "7", ExtraTTL: 0, } TRANSFERS_REGIONS APICacheKey = APICacheKey{ Key: "8", ExtraTTL: 0, } SEARCH APICacheKey = APICacheKey{ Key: "9", ExtraTTL: 0, } )
Implemented for kickcore/api package
type Cache ¶
type Cache struct {
// It's true if you call c.Close()
Closed bool
Logger *logging.FileLogger
// contains filtered or unexported fields
}
func (*Cache) CacheFunc ¶
func (c *Cache) CacheFunc(apikey APICacheKey, key string, f func() ([]byte, error)) ([]byte, bool, error)
CacheFunc first tries to returns value from cache, then if key not found in cache, call 'f' and (if it not returned error,) insert returned data into cache
returns (data, data is in cache, error)
func (*Cache) CacheFuncJSON ¶
func (c *Cache) CacheFuncJSON(apikey APICacheKey, key string, f func() (interface{}, error)) ([]byte, bool, error)
Like c.CacheFunc, but recieve interface{} from 'f' and convert it to bytes by json.Marshal.
func (*Cache) Delete ¶
func (c *Cache) Delete(apikey APICacheKey, key string) (bool, error)
Delete value specified by the key.
func (*Cache) DeleteMany ¶
Delete values which are specified by the keys.
type CacheDriver ¶
type CacheDriver interface {
// Initialize cache
Init() error
// Pings cache connection
PingContext(ctx context.Context) error
// Inserts key-value to cache
// Returns false if key is currently in cache
Insert(key string, value []byte, date int64) (bool, error)
// Selects the value specified by key in cache.
Select(key string, value *[]byte) error
// Selects the keys which are expired.
SelectExpiredValues(expireAfter int64) ([]string, error)
// Deletes the value specified by key in cache.
Delete(key string) (bool, error)
// Deletes the values which are specified by any key in cache.
DeleteMany(keys []string) (int64, error)
// Returns the length of cache
Len() (int64, error)
// Closes cache
Close() error
}
type ExpirationMachine ¶
type ExpirationMachine struct {
// Cache
ActiveCache *Cache
// contains filtered or unexported fields
}
Expiration Machine - deletes values which are expired.
func (*ExpirationMachine) IsStarted ¶
func (e *ExpirationMachine) IsStarted() bool
func (*ExpirationMachine) Stop ¶
func (e *ExpirationMachine) Stop() error
Click to show internal directories.
Click to hide internal directories.