We want a java class developed that is a (syncronizable) key-value store.
This shall be backed by a an in memory datastore (hashmap?, arraylist? ) of objects with the following properties
- key (string)
- value (string)
- sync_state (int)
- timestamp (TIMESTAMP (long?))
- is_deleted (boolean)
For this we want a 'class' that implements the following methods:
setItem(key, value)
- add or update the value identified by key.
- set sync_state=1
- new items get NULL or zero for timestamp,
removeItem(key)
- set is_deleted=true for item
- set sync_state=1
getItem(key)
- return value of item
- if item is_deleted this is the same as if the item doesn't exist
getItems()
- return array of key, value pairs
- if item is_deleted = 1 then do not include item
- return empty array if no items defined
In addition for synchronizing this key-value store we need:
getChanges
- return an object with
{
maxTimestamp: (the max value of all timestamps in the database)
items: [
{key: ..., value: ..., timestamp: ..., is_deleted: ... },
{key: ..., value: ..., timestamp: ..., is_deleted: ... },
{key: ..., value: ..., timestamp: ..., is_deleted: ... },
{key: ..., value: ..., timestamp: ..., is_deleted: ... },
... etc ...
]}
- items are all objects in the map with sync_state=1
updateChanges(arrayOfNewAndChangedItems)
- the argument arrayOfNewAndChangedItems is a list of
{key: ..., value: ..., timestamp: ..., is_deleted: ... }
- these should update existing items based on key or add new items. sync_state is set to 0.
Dear Sir, I think this must be done using a thread-safe HashMap as in-memory datastore.
As a sample of what I can do for you, I have attached a .java class file already implementing getItem, setItem, removeItem and getItems in your PMB;
I will add the getChanges and updateChanges methods according to your specifications within one day if you hire me,
and modify the class if you require, until you are satisfied.
$60 USD på 1 dag
5,0 (1 bedømmelse)
1,6
1,6
25 freelancere byder i gennemsnit $84 USD på dette job
Software Engineer by day, over 10 years' experience across all major languages. Dipping toes into contracting.
Low rates due to first time bid.
5 days will allow an initial solution to be provided, with feedback across timezones and finally an updated version conforming to delivery specs.
Further details in private message.