NICOS cache clients.
Bases: nicos.core.device.Device
Bases: Device
An extensible read/write client for the NICOS cache.
Parameters
Cache key prefix.
“host:port” of the cache instance to connect to.
Parameters inherited from the base classes: description, loglevel, lowlevel
Bases: nicos.cache.client.BaseCacheClient
Bases: BaseCacheClient
Parameters inherited from the base classes: description, loglevel, lowlevel, prefix, server
Bases: nicos.cache.client.CacheClient
Bases: CacheClient
Parameters inherited from the base classes: description, loglevel, lowlevel, prefix, server
NICOS cache server.
The Cache server listens by default on TCP and UDP port 14869 (it will also receive UDP broadcasts).
The protocol is line-based. The basic syntax for a line (requests and responses) is
[time1] [+|-] [time2] [@] key op [value] crlf
The op is one character and decides the basic meaning of the request or response.
Keys are hierarchic, with levels separated by an arbitrary number of slashes.
All values are strings. The cache server does not interpret them in any way, but the NICOS clients do.
Examples:
1327504784.71+5@nicos/temp/value=5.003 # explicit time and ttl given
nicos/temp/setpoint=5 # no time and ttl given
+5@nicos/temp/value=1.102 # only ttl given
nicos/temp/value= # key deletion
Response: none.
Examples:
nicos/temp/value? # request only the value
@nicos/temp/value? # request value with timestamp
1327504780-1327504790@nicos/temp/value? # request all values in time range
Response: except for history queries, a single line in the form key=value or time@key=value, see below. If the key is nonexistent or expired, the form is [time@]key! or [time@]key!value. For history queries, a number of lines of the same form.
Examples:
nicos/temp/* # request only values
@nicos/temp/* # request values with timestamps
Response: each value whose key contains the key given is returned as a single line as for single query.
Response: none immediately, but every update matching the given key is sent to the client, either as [time@]key=value or [time@]key!value (if the key has expired).
The lock mechanism allows only one client at the same time to obtain a lock on a given identifier. This can be used to synchronize access of multiple NICOS clients to a shared resource (but is slow!).
Response:
on lock: one of
key$otherclientid # already locked by other client, request denied
key$ # locked successfully
on unlock: one of
key$otherclientid # not locked by this client, request denied
key$ # unlocked successfully
Bases: nicos.core.device.Device
Bases: Device
Parameters inherited from the base classes: description, loglevel, lowlevel
Bases: nicos.core.device.Device
Bases: Device
The server class.
Attached devices
The cache database instance. Type: CacheDatabase.
Parameters
Address to bind to (host or host:port).
Parameters inherited from the base classes: description, loglevel, lowlevel
Bases: object
An UDP connection to use instead of a TCP connection in the CacheWorker.
Bases: object
Pseudo-queue for synchronous writes to UDP connections.
Bases: nicos.cache.server.CacheWorker
Bases: CacheWorker
Bases: object
Worker thread class for the cache server.
Check if we need to send the update given.
Bases: nicos.cache.server.CacheDatabase
Bases: CacheDatabase
Cache database which writes historical values to disk in a flatfile (ASCII) format.
The store format is the following:
For example, the cache entries for category “nicos/slit” at 2012-01-05 are available in the files nicos-slit/2012/01-05 and 2012/01-05/nicos-slit.
The format of these files is a simple three-column tab-separated ascii format: the first column is the last part of the cache key (which combined with the category gives the full key); the second column is the Unix timestamp of the change, and the third column is the actual value.
All values should be valid Python literals, but this is not enforced by the cache server, rather by the NICOS clients. The value can also a single dash, this indicates that at the given timestamp the latest value for this key expired.
Parameters
Directory where history stores should be saved.
Parameters inherited from the base classes: description, loglevel, lowlevel
Bases: nicos.cache.server.CacheDatabase
Bases: CacheDatabase
Central database of cache values, keeps everything in memory.
Parameters inherited from the base classes: description, loglevel, lowlevel