Cache server class.
read only clients:List<SlaveClient>
Slave servers list. May be needed for sending notifications to a list of servers. Do not modify in any way.
inline addModule (m:Dynamic):Void
Adds initialized module to the server list.
Parameters:
m
Initialized server module.
inline broadcast (type:String, msg:Dynamic):Void
Broadcasts a notification to all servers of this type.
Server notifications are described in Notifications article.
The message object has to have _type
string field with message type.
Parameters:
type
Server type.
msg
Server message. Anonymous object.
getClient (id:Int):SlaveClient
Returns slave client by its ID.
Parameters:
id
Slave client ID.
Returns:
Slave client. Returns null if no client was found.
getClientByConnectionID (id:Int):SlaveClient
Returns slave client by its connection ID. Only works for slave clients connected through network.
Parameters:
id
Slave client connection ID.
Returns:
Slave client instance. Returns null if no client was found.
getClientByType (t:String):SlaveClient
Returns first slave client with this type.
Parameters:
t
Slave client type.
Returns:
Slave client. Returns null if no clients were found.
getModule (name:String):Dynamic
Returns a server module by its name.
Parameters:
name
Server module name.
Returns:
Server module.
getModuleList ():List<ModuleCache<CacheServer>>
Returns a list of available server modules.
Returns:
Server modules list.
getRandomClient (t:String):SlaveClient
Returns random slave client with this type.
Parameters:
t
Slave client type.
Returns:
Slave client.
getSubscribedMethods (tag:String):Null<List<Dynamic>>
Returns a list of subscribed methods for a given event type. Module subscription API is described in detail in Subscriptions article.
Parameters:
tag
Event type.
Returns:
List of methods subscribed to this event type.
getSubscribedModules (tag:String):List<ModuleCache<CacheServer>>
Returns subscribed modules list for this event name.
Parameters:
tag
Event name.
Returns:
Server modules list.
initServer ():Void
Initializes cache server state and variables. Must be called before calling start()
.
loadModules (list:Array<Dynamic>):Void
Loads and initializes specified server modules.
Parameters:
list
List of server module classes.
inline log (type:String, s:String, ?logStack:Bool):Void
Adds a typed message to cache server log.
Parameters:
type
Log message type.
s
Log message.
logStack
Log call stack.
Returns next available row ID from sequence for given database table.
Parameters:
t
Database table name.
Returns:
Next available row ID.
inline pending (q:String):Void
Adds pending SQL query to the queue. Does not wait for result.
Parameters:
q
SQL query string.
inline query (q:String):ResultSet
Runs SQL query through one of the database manager connections.
Parameters:
q
SQL query string.
Returns:
The result of the query.
inline quote (s:String):String
Escapes a string for using in SQL query as a row field.
Parameters:
s
String.
Returns:
Escaped string.
subscribeMethod (tag:String, method:Dynamic):Void
Subscribes method to an event. Module subscription API is described in detail in Subscriptions article.
Parameters:
tag
Event type.
method
Method.
subscribeModule (tag:String, module:Dynamic):Void
Subscribes module to an event. Server subscriptions are described in detail in Subscriptions article.
Parameters:
tag
Event name.
module
Server module.