Documentation ¶
Index ¶
- Constants
- type CacheContainer
- func (c *CacheContainer) Flush(withLock bool) error
- func (c *CacheContainer) Get(m map[string]interface{}) ([]interface{}, error)
- func (c *CacheContainer) GetBySquirrel(squirrelArgs ...interface{}) ([]interface{}, error)
- func (c *CacheContainer) GetOne(uniqueIdentityValue interface{}) (interface{}, error)
- func (c *CacheContainer) GetStatistic() map[string]map[string]interface{}
- func (c *CacheContainer) Insert(in ...interface{}) (map[string]int64, error)
- func (c *CacheContainer) InsertAsync(in ...interface{}) error
- func (c *CacheContainer) Remove(uniqueIdentities ...interface{}) (map[string]int64, error)
- func (c *CacheContainer) RemoveFromCache(uniqueIdentities ...interface{})
- func (c *CacheContainer) RemoveIndirect(m map[string]interface{}) (map[string]int64, error)
- type CacheWB
- func (c *CacheWB) FlushAll(withLock bool)
- func (c *CacheWB) GetContainer(tableName string, cfg Config, objType interface{}) *CacheContainer
- func (c *CacheWB) GetViewContainer(viewName string, viewQuery string, cfg Config, objType interface{}) *CacheContainer
- func (c *CacheWB) GracefulShutdown() bool
- type Config
- type ConfigMysql
- type EmbedME
- type StorageKind
Constants ¶
const ( IntervalWorkerMaintainer = 10 IntervalWorkerQueryIndexMaintainer = 500 CacheInsertAsyncLatency = 1 CacheFlushUpdatesLatencyTime = 30 CacheFlushUpdatesLatencyCount = 10 AccessTTLItems = 10 AccessTTLQueryIndex = 10 )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CacheContainer ¶
type CacheContainer struct {
// contains filtered or unexported fields
}
func (*CacheContainer) Flush ¶
func (c *CacheContainer) Flush(withLock bool) error
Flush all updates in container to storage
func (*CacheContainer) Get ¶
func (c *CacheContainer) Get(m map[string]interface{}) ([]interface{}, error)
Return an array of Items from cache. This method check cache first, and then search in storage, if not found. parameter m stand for query
func (*CacheContainer) GetBySquirrel ¶
func (c *CacheContainer) GetBySquirrel(squirrelArgs ...interface{}) ([]interface{}, error)
Return an array of Items from cache. This method check cache first, and then search in storage, if not found. parameter squirrelArgs is an where query build by squirrel library you can find its document in github.com/Masterminds/squirrel
func (*CacheContainer) GetOne ¶
func (c *CacheContainer) GetOne(uniqueIdentityValue interface{}) (interface{}, error)
Return an Item from cache. This method check cache first, and then search in storage, if not found. It return result for uniqueIdentityValue, if there was, if there were more than one result, you should use Get()
func (*CacheContainer) GetStatistic ¶
func (c *CacheContainer) GetStatistic() map[string]map[string]interface{}
func (*CacheContainer) Insert ¶
func (c *CacheContainer) Insert(in ...interface{}) (map[string]int64, error)
Insert Items to container. Item add to database synchronously,
func (*CacheContainer) InsertAsync ¶
func (c *CacheContainer) InsertAsync(in ...interface{}) error
Asynchronously insert items to container. Items bulk insert to database.
func (*CacheContainer) Remove ¶
func (c *CacheContainer) Remove(uniqueIdentities ...interface{}) (map[string]int64, error)
Remove from cache and storage just by uniqueIdentities
func (*CacheContainer) RemoveFromCache ¶
func (c *CacheContainer) RemoveFromCache(uniqueIdentities ...interface{})
Remove from cache just by uniqueIdentities
func (*CacheContainer) RemoveIndirect ¶
func (c *CacheContainer) RemoveIndirect(m map[string]interface{}) (map[string]int64, error)
Remove from cache and storage by any keys (caution: This method may have some overload on storage) Unlike method `Remove`, You can use `RemoveIndirect` to removeByUniqueIdentity from cache and storage by any keys. First, RemoveIndirect call storage.Get() by keys and values arguments, internally, to find uniqueIdentities. And then removeByUniqueIdentity then by uniqueIdentities through the `Remove` method
type CacheWB ¶
type CacheWB struct {
// contains filtered or unexported fields
}
func (*CacheWB) FlushAll ¶
Flush all data remained in cache (for all containers), but not flushed to database yet. withLock cause to avoid any updates on container (while the container is flushing)
func (*CacheWB) GetContainer ¶
func (c *CacheWB) GetContainer(tableName string, cfg Config, objType interface{}) *CacheContainer
Get the container of given table name, with type of objType, objType is a variable of an structure that will contain a row of table
func (*CacheWB) GetViewContainer ¶
func (c *CacheWB) GetViewContainer(viewName string, viewQuery string, cfg Config, objType interface{}) *CacheContainer
func (*CacheWB) GracefulShutdown ¶
GracefulShutdown avoid all new update in all container and flush all containers too. After calling it, no update accepts.
type Config ¶
type Config struct { // Interval of maintainer worker. // The worker check items of cache for theirs update and time to live status // Default is 10 seconds IntervalWorkerMaintainer int // Interval of QueryIndexMaintainer worker. // QueryIndexMaintainer check items of QueryIndex in cache for theirs time to live status // Default is 500 seconds IntervalWorkerQueryIndexMaintainer int // Maximum time, Insert worker wait for new update to make batch insert. // This parameter is corresponding to InsertAsync // Default is 1 second CacheInsertAsyncLatency int // For an item in cache: Maximum time after last update, that updates flush to storage // Default is 30 seconds CacheFlushUpdatesLatencyTime int // For an item in cache: Maximum updates count, that updates flush to storage // Default is 10 seconds CacheFlushUpdatesLatencyCount int // Type of database StorageName StorageKind // Config of database is using Database interface{} // Maximum time an item will remain in cache without any access. Then it will be removed // Default is 10 seconds AccessTTLItems int // Maximum time an QueryIndex will remain in cache without any access. Then it will be removed // Default is 10 seconds AccessTTLQueryIndex int // Enable Log // Default is false Log bool // Enable gathering statistics // Default is false Statistic bool }
type ConfigMysql ¶
type EmbedME ¶
type EmbedME struct {
// contains filtered or unexported fields
}
func (*EmbedME) UpdateStorage ¶
Flush updates of holder item in storage