Data cache manager. Data blocks are described in detail in Data Blocks article.
inline addModule (m:Dynamic):Void
Adds initialized cache module to list.
Parameters:
m
Initialized cache module.
create (serverID:Int, type:String, id:Int, ?attrs:Dynamic, ?queryFunc:_QueryFunc):_CacheCreateReturnType
Creates data block in database. Does not load it into memory.
Parameters:
serverID
Slave server ID that does the operation.
type
Data cache type.
id
Data block ID.
attrs
Optional. Data block attributes object.
queryFunc
Optional. Function for making SQL query. Will use one of the database manager connections by default.
Returns:
Operation status.
get (serverID:Int, type:String, id:Int, currentVersion:Int, ?queryFunc:_QueryFunc):_CacheReturnType
Gets data block from cache and locks it for usage. If the block is not in cache, loads it from database.
Parameters:
serverID
Slave server ID that does the operation.
type
Data cache type.
id
Data block ID.
currentVersion
Current block version.
queryFunc
Optional. Function for making SQL query. Will use one of the database manager connections by default.
Returns:
Operation status and block contents.
getAsync (serverID:Int, type:String, id:Int, params:Dynamic, postFunc:_AsyncWorkerFunc):Void
Gets data block from cache asynchronously and locks it for usage. If the block is not in cache, loads it from database asynchronously. Uses asynchronous database manager and asynchronous worker threads.
Parameters:
serverID
Slave server ID that does the operation.
type
Data cache type.
id
Data block ID.
params
Parameters given to callback function.
postFunc
Function that runs after the block is loaded.
Will run in one of the asynchronous worker threads.
Called like this: postFunc(async, serverID, params)
.
"params" is the parameters object given to function with additional "__return" field (snipe.cache._CacheReturnType class) that contains operation error code and cache block (block is null in case of error).
getServerID (type:String, id:Int):Int
Gets slave server ID that has that data block locked.
Parameters:
type
Data cache type.
id
Data block ID.
Returns:
Slave server ID.
getUnlocked (serverID:Int, type:String, id:Int, currentVersion:Int, ?queryFunc:_QueryFunc):_CacheReturnType
Gets data block from cache without locking it. If the block is not in cache, loads it from database.
Parameters:
serverID
Slave server ID that does the operation.
type
Data cache type.
id
Data block ID.
currentVersion
Current block version.
queryFunc
Optional. Function for making SQL query. Will use one of the database manager connections by default.
Returns:
Operation status and block contents.
unlock (serverID:Int, type:String, id:Int):Void
Unlocks this data block.
Parameters:
serverID
Slave server ID that does the operation.
type
Data cache type.
id
Data block ID.
update (serverID:Int, type:String, id:Int, diff:_BlockDiff, doUnlock:Bool):_CacheUpdateReturnType
Updates data block contents and increases version.
Must only be called on data blocks that are locked by this slave server.
Parameters:
serverID
Slave server ID that does the operation.
type
Data cache type.
id
Data block ID.
diff
Data block changes.
doUnlock
If enabled, will unlock data block after the update.
Returns:
Operation status.
updateRaw (serverID:Int, type:String, id:Int, obj:Dynamic):_CacheUpdateReturnType
Updates data block contents and increases version using anonymous object instead of diff.
Must only be called on data blocks that are locked by this slave server.
Mainly used by the editor.
Parameters:
serverID
Slave server ID that does the operation.
type
Data cache type.
id
Data block ID.
obj
Data block changes as an anonymous object.
Returns:
Operation status.
updated (serverID:Int, type:String, id:Int):Void
Marks the block as updated. This method should be used if you've made some changes in the block with Block.set()
on the cache server.
Must only be called on data blocks that are locked by this slave server.
Parameters:
serverID
Slave server ID that does the operation.
type
Data cache type.
id
Data block ID.