I’m exploring UDF and Large Data Type to see if it is possible to build a queue with the following desirable requirement:
- no duplication for task id
The idea is implement with Large List and Large Map
- Large List: store Priority+separator+TaskID as a string value. As it’s sorted, the first item will be the highest priority task.
- Large Map: store TaskID as key, and task content as value
Then there are two UDF APIs:
- add(TaskID, Priority, TaskDetails): check the map for duplication, if not, then add to the LList and LMap.
- poll(): scan the list for the first time, split the value for TaskID, and get task content from LMap, then remove from LList and LMap
In theory it should work. A problem is only that the [LLIST API] (https://github.com/aerospike/aerospike-lua-core/blob/master/src/external/llist.lua) doesn’t provide a way for me to get the first N items easily. I think the scan api should have a way to limit to top 1%, (haven’t figured it out yet) but ideally, a “LIMIT” keywords that give me only the first N records.
Anyway comment or idea? Thanks in advance.