inthefabric / RexConnect

Connect to Rexster/RexPro via TCP connection.
www.inthefabric.com
Other
10 stars 0 forks source link

Cached Query Scripts #36

Closed zachkinstner closed 11 years ago

zachkinstner commented 11 years ago

RexConnect could cache certain query scripts (when specified), and allow commands to refer to the cached script key instead of sending the entire script text again. This is an additional way to reduce the request/response sizes (see #35). This may also require something like command-level options (similar to #17). Some initial ideas:

First request This adds a third (optional) query command argument. It tells RexConnect to cache the script, using the provided value as the cache key.

{
  "reqId": "0",
  "cmdList": [
    {
      "cmdId": "0",
      "cmd": "query",
      "args": [
        "g.addVertex([TestId:_P0]);plus.lots.of.other().things.to.do.here();",
        "{\"_P0\": 123}",
        "addV"
      ]
    }
  ]
}

Subsequent requests This adds a new queryc command, which is identical to the query command, except it takes a cache key as the first parameter instead of a script.

{
  "reqId": "1",
  "cmdList": [
    {
      "cmdId": "0",
      "cmd": "queryc",
      "args": [
        "addV",
        "{\"_P0\": 234}"
      ],
    }
  ]
}
zachkinstner commented 11 years ago

The effect isn't very impressive in the example above, but this could greatly reduce request size for when long scripts are involved.

The approach above would be a shortcut for adding a script to the cache. A new cache command would support adding, removing, remove all, and returning the script (if present) associated with a cache key.

zachkinstner commented 11 years ago

Possible cache command arguments:

zachkinstner commented 11 years ago

The new query argument and new queryc command need to be documented on the wiki.

Also, moved the cache command notes to #38.

zachkinstner commented 11 years ago

Done: https://github.com/inthefabric/RexConnect/wiki/RexConnect-Commands