Skip to content
This repository has been archived by the owner on Aug 20, 2022. It is now read-only.

KeyValueStore Single Callback for Multiple Concurrent Gets #10

Closed
rdev34 opened this issue Aug 26, 2020 · 2 comments
Closed

KeyValueStore Single Callback for Multiple Concurrent Gets #10

rdev34 opened this issue Aug 26, 2020 · 2 comments
Assignees
Labels
enhancement New feature or request

Comments

@rdev34
Copy link
Collaborator

rdev34 commented Aug 26, 2020

I ran into the issue where I needed to grab 3 KeyValueStore values at once and saw two ways to structure my code:

  1. Nest the requests so that second request is inside callback of first, etc
  2. Do all requests concurrently and monitor status of requests until all are complete.

Option 1) is favored because of the low complexity to achieve a block of code that will handle all 3 values, but results in disgusting nesting of KVS requests.
Option 2) has no nesting, but is too complex and verbose to leverage easily because of the need to spin up a thread to wait for the requests.

We need a KeyValueStore Get solution that uses Option 2) under the hood. It runs all the requests concurrently (or aggregates to 1 request), and returns all the results in a single callback.

@rdev34 rdev34 added the enhancement New feature or request label Aug 26, 2020
@rdev34 rdev34 self-assigned this Aug 28, 2020
@rdev34
Copy link
Collaborator Author

rdev34 commented Aug 28, 2020

Done, KeyValueStore:Get now supports a table of values like:

KeyValueStore:Get({"Key1", "Key2"}, function(values) 
    print(values["Key1"])
    print(values["Key2"])
end)

@rdev34 rdev34 closed this as completed Aug 28, 2020
@rdev34
Copy link
Collaborator Author

rdev34 commented Aug 28, 2020

Uses KeyValueStore:Get internally to take advantage of caching

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant