Runtime components : Service components : Remote cache service : How remote cache works
  
How remote cache works
High level architecture
The remote cache makes use of Redis, an in-memory data structure store that can be used as a database, cache, and message broker. For more information, see https://redis.io/.
This graphic is described in the surrounding text.
UDTT data flow and APIs
UDTT uses APIs to pull, push, and drop data to and from the remote cache.
This graphic is described in the surrounding text.
To support indexing and filtering of a large List in Radis, Remote Cache Service also provides these methods (pseudo API):
list_push(list, keyset, position): used to push <list> to a remote list at <position> and using <keyset> for indexing and filtering later.
list_pull(list, condition, index, stopIndex): used to pull <list> matching the <condition> from remote list from <index> to <stopIndex>, where <condition> is a Lua expression that returns a Boolean value to indicate whether the current record is included or not.
For example: tonumber(R['accountBalance']) > 100.00, where R['accountBalance'] means the value of the field accountBalance of the current record and tonumber(…) is a function of Lua to get the value in number type.
There are also lock and unlock APIs:
lock(resoure): to obtain a lock to prevent data being updated while an operation is in progress
unlock(resoure): to release the lock
The APIs mentioned here are pseudo code. For the actual APIs, see Class and API reference.
Note The remote cache can speed up data access and improve application efficiency but there is a performance impact associated with accessing the cache. The more frequently you push and pull data to and from the cache, the lower the performance due to the network activity and the overhead that is associated with managing access to the shared resource.
Access data with no coding required
To reduce development effort, a special operation class is provided:
com.unicomsi.udtt.rcache.RCacheOperation
where RCacheOperation is an enhanced copy of BTTServerOperation class, see class RCacheOperation.
To read, write, or delete data to/from the cache, you define an operation with this class (or its extension), and define the data of the operation with the following parameters:
remoteCache : value
where value is a string with one of the following values:
NULL or empty: the remote cache is not used
R: read/pull data from the remote cache before the operation
W: write/push data to the remote cache after the operation
D: delete/drop data from the remote cache after the operation
remoteKey : value
where value is a string with one of the following values:
NULL or empty: use the name of the data element as the key, that is:
key = dataElement.getName()
the key of the remote data to read, write, or delete to/from the remote cache
$string (a string that is prefaced with the ‘$’ character): retrieve the key from the current context, that is:
key = thisContext.getValueAt("string")
To access a large list in the remote cache, you also need these parameters:
Cache_List_Key_Set : value
Define the fields set of the record of this list for indexing and filtering later, where value is a string such as “accountNo, accountBalance, …”. You should modify it through the tooling editor.
Cache_List_Filter : value
Defined the criteria for the current record of the remote List on pull, count and find operations. Where value is a Lua expression that returns a Boolean value to indicate whether the current record is included or not.
You should reference the indexed data field of the list in the form R[‘fieldName’], where the fieldName must be in the Cache_List_Key_Set as above. For example, “tonumber(R['accountBalance']) > 100.00”, where R['accountBalance'] means the value of the field accountBalance of the current record, and tonumber(…) is a function of Lua to get a numerical value.
Cache_List_Index : value
Define the position(inclusive) where the operation(push, pull and pop) should begin.
Where value is a number starting from 0, negative numbers indicate offsets starting from the end of the list, such as:
-1 denotes the last record of the remote list
-2 the penultimate, and so on
Specifically it accepts these 2 constants:
LIST_HEAD: 0, the first record
LIST_TAIL: -1, the last record
Cache_List_Stop : value
Define the position(inclusive) where the operation(push, pull and pop) should stop.
Where value is a number with the same form as Cache_List_Index.
No additional coding is required.
For example, as shown in the following image, you can define an operation:
implClass= com.unicomsi.udtt.rcache.RCacheOperation;
quota(data parameters)
    remoteCache=R
    remoteKey=$fund.code
This graphic is described in the surrounding text.
When you run the operation, data is read from the cache by using the value of fund.code (in the current context) as the key. See Access data by using RCacheOperation for the detailed steps.
See also:
Go up to
Remote cache service