This is not a topic I know that much about (hence this question) so the title and anything else might be bit off, feel free to edit. or suggest changes.
I'm not even sure if this is the correct stack exchange site for this type of question, but it's my best guess (if you think another would be better suited please drop a comment).
type annotations
are to help clarify; [T;n]
is an array of T
values of length n
I want to cache data server-side between client interactions.
I have a web application which has a sequence of AJAX calls following:
- A user upload a greyscale image (
[uint;n]
). - The application converts this image to a binary image (
255
or0
,[bool;n]
) and then finds the bounds around non-contiguous areas of black ([(uint,uint);m]
), then returns these bounds. - The user judges whether these bounds are accurate, with client-side returning
[bool;m]
Between 2. and 3. the server is using user feedback to filter [(uint,uint);m]
. To do this I can see 2 ways:
Approach 1: The servers sends the [(uint,uint);m]
to the client which then sends a modified [(uint,uint);m]
back.
Approach 2: The server caches and then sends[(uint,uint);m]
to the client which then sends[bool;m]
back.
Approach 2 is desirable as this is far less data being sent to the server, 128 times less data (1*m
Vs 2*64*m
, when m=100
, 13 bytes
Vs 1600 bytes
).
I need some fast way to cache these values between client interactions, a list where bounds can be pushed and pulled from quickly (like a queue)(and where items push with a timestamp and get deleted after a time limit).
My issues arise when thinking that in deployment client calls may be sent to different instances running on different cores or possibly even different systems.
Using a list wouldn't work across cores, using an in-memory data store (like redis) I think wouldn't work across systems.
Is there a good approach to this problem or should I simply go with approach 1?
[(uint,uint;m)]
mean (at step 2) according to your type annotations? Did you mean[(uint,uint);m]
?