Runtime tools : Service components : Remote cache service : Class and API reference : The additional APIs for large lists
  
The additional APIs for large lists
Additional APIs for use with large lists
See
Push list
Push Record
Set List
Pull List
Count list
Find list
Pop list
Trim list
Get list
List size
Drop list
Push list
abstract public long list_push(IndexedCollection list, String key, long index) throws IOException
Push list <list> to remote list (in the cache) with key <key> at index position <index>.
Returns the size of the remote list.
Note  
If the remote list does not exist, the list is created.
You can add elements to the beginning or the end of an existing list. For performance reasons, you cannot add elements in the middle of the list.
Normally the list is only a small part of the remote list; to build a large remote list, call this method multiple times.
Do not attempt to overwrite existing data. Instead, delete the remote list by using list_drop(list,key) and create a new list.
The following table describes the parameters:
 
Parameter
Description
List
The data to be pushed.
Defines the Cache_List_Key_Set parameter for filtering on poll at a later date.
Key
The key for the remote list
Index
The record position (in the remote list) to which data is pushed.
Supported options are:
LIST_HEAD: 0 (the first record)
LIST_TAIL: -1 (the last record)
Push Record
abstract public long list_push(IndexedCollection list, KeyedCollection record, String key, long index) throws IOException
Push record <record> to remote List (in the cache) with key <key> at index position <index>.
Provides the definition for the remote list, and pushes a record to the remote list.
Set List
abstract public boolean list_set (IndexedCollection list, KeyedCollection record, String key, long index) throws IOException ;
Set(replace) the <record> of the remote List with <key> at position <index>.
The following table describes the parameters:
 
Parameter
Description
List
Read only and will not be pushed to remote, it only provides the <Cache_List_Key_Set> definition
Record
The data to be updated (replaced with), read only
Key
The key for the remote list
Index
The record position (in the remote list) to be updated (replaced with), start from 0
LIST_HEAD or 0 denotes the first record
Pull List
abstract public long list_pull(IndexedCollection list, String key, String filter, long index, long stop) throws IOException
Pull data from the remote List with <key> to <list> and using <filter> to filter the remote List from <index>(0 based) to <stop>(include)
The following table describes the parameters:
 
Parameter
Description
List
Data to be pulled from remote; its local data would be cleared and overwritten
Key
The key for the remote list
Filter
Define the criteria for the current record of the remote List on pull, count and find operations.
Define a Lua expression that returns a Boolean value to indicate whether the current record is included (true) or not (false).
You can reference the indexed field of the current record of the list in the form of ‘R["dataFieldName"]’as a Lua string value.
To use it as number: number(R["dataFieldName"])
You can reference the position of the current record with POS, start from 0;
You can use these Lua functions/libs in the expression:
tonumber -- tostring -- math -- string -- table
Example:
tonumber(R["found.balance"]) > 100 and POS < 10
Where "found.balance" should be in the Cache_List_Key_Set index.
Index
The record position (in the remote list) to begin the process, starting from 0
LIST_HEAD or 0 denotes the first record
Count list
abstract public long list_count(IndexedCollection list, String key, String filter, long index, long stop)
Count the <list> items matching < filter > from <index> to <stop>
Returns only the count number of matched records, and no other data.
Find list
abstract public long list_find(IndexedCollection list, String key, String filter, long index) throws IOException ;
Find the item matching <filter> of remote <list> from <index>
Returns only the index number of the first matched record, no other data.
Pop list
abstract public boolean list_pop (IndexedCollection list, KeyedCollection record, String key, long index) throws IOException ;
Pop out ONE record from the head (<index>=LIST_HEAD) or tail (<index>=LIST_TAIL) of the remote List with <key> to local <record>
 
Parameter
Description
List
Read only and will not be pushed to remote, it only provides the <Cache_List_Key_Set> definition
Record
The popped data that will overwrite local data
Key
The key for the remote list
Index
The record position (in the remote list) to be popped out.
Supported options are:
LIST_HEAD: 0 (the first record)
LIST_TAIL: -1 (the last record)
Trim list
abstract public boolean list_trim(IndexedCollection list, String key, long index, long stop) throws IOException ;
Trim the remote List with <key> to new size(from <index> to <stop>) and drop other records([0~<index>] and [stop+1, LIST_TAIL])
 
Parameter
Description
List
Read only and only provides the <Cache_List_Key_Set> definition of the remote list.
Key
The key for the remote list
Index
The first record position at remote List to KEEP, start from 0
Supported options are:
LIST_HEAD: 0 (the first record)
LIST_TAIL: -1 (the last record)
Stop
The last record position at remote List to KEEP, start from 0
This can also be negative numbers, indicating offsets starting from the end of the list.
For example, LIST_TAIL or -1 denotes the last record of the remote list, -2 the penultimate, and so on.
Get list
abstract public boolean list_get (KeyedCollection record, String key, long index) throws IOException ;
Get <record> from the remote List with <key> by <index>
 
Parameter
Description
Record
The data to be saved to, its local data would be cleared and overwritten
Key
The key for the remote list
Index
The first record position at remote List to get, start from 0
LIST_HEAD: 0 (the first record)
This can also be negative numbers, indicating offsets starting from the end of the list.
For example, LIST_TAIL or -1 denotes the last record of the remote list, -2 the penultimate, and so on.
List size
abstract public long list_size (String key) ;
Get the size of the remote List with <key>
Drop list
abstract public boolean list_drop (IndexedCollection list, String key);
Drop the remote List with <key> completely.
See also:
Go up to
Class and API reference