Welcome to JCache

Copyright © 2013-2015 Jim Rosenblum

Version: v0.9.5

Authors: Jim Rosenblum (jrosenblum@carelogistics.com).

JC

Erlang, Distributable, In-Memory Cache

JSON-Query; Consistency Assist; and Simple, TCP Interoperability Protocol

Features

Cache Functions (jc)

Consistency Supported Functions (jc_s)

Identical to the Create and Evict family of functions of the jc module (see above), except:

Eviction Manager Functions (jc_eviction_manager)

Pub/Sub Functions (jc_psub)

{jc_node_events, {nodedown, DownedNode, [ActiveNodes],[ConfiguredNodes]}}

{jc_node_events, {nodeup, UppedNode, [ActiveNodes],[ConfiguredNodes]}}

Indexing Functions (jc_store)

Bridge Functions (jc_bridge)

{From, {Fn, P1, P2,...}}

for each paramater, as in

jc_bridge ! {Pid, {put, Map, Key, Value}}

{From, {node_topic_sub}} -> ok | {error, badarg}, client will recieve:

{jc_node_events, {nodedown, DownedNode, [ActiveNodes],[ConfiguredNodes]}}

or

{jc_node_events, {nodeup, UppedNode, [ActiveNodes],[ConfiguredNodes]}}

{From, {node_topic_unsub}} -> ok.

Interoperability: String protocol

This is a binary-encoded, string protocol used to provide socket-based interoperability with JC.

All messages to the cache system are string representations of a tuple, All messages form the caching system to the client are JSON

The protocol defines three message types: CONNECT, CLOSE and COMMAND all of which are binary strings consisting of an 8-byte size followed by the actual command messages.

Responses are also binary strings with an 8-byte size prefix.

The CONNECT command initiates a session,

M = <<"{connect,{version,\"1.0\"}}">>

Size is 25, so the CONNECT message is:

<<25:8, M/binary>> = 
<<25,40,58,99,111,110,110,101,99,116,32,123,58,118,101,
  114,115,105,111,110,32,49,46,48,125,41>>

The server will respond to a CONNECT command with either an error or the encoded version of {"version":" "1.0""}

<<15:8, <<"{\"version\":1.0}">> = 
<<15,123,34,118,101,114,115,105,111,110,34,58,49,46,48,125>>

The CLOSE command closes the socket, ending the session

M = <<"{close}">>

 Size is 7 so the CLOSE message is:
 <<7,123,99,108,111,115,101,125>>

COMMAND messages are string versions of the tuple-messages which jc_bridge uses only without the self() parameter. For example

{self(), {put, Map, Key, Value}} becomes 
{put, Map, Key, Value}

The return will be an encoded version of a JSON string. A client session might look as follows:

client:send("{put, evs, \"1\", \"{\\\"value:\\\":true}\"}")
<<"{\"ok\":1}">>

client:send("{get, evs, \"1\"}"),
    <<"{\"ok\":"{\\\"value\\\":true}\"}">>

Configuration

Application Modules

Build Instructions

[root@db01] git clone https://github.com/jr0senblum/jc.git

Documentation

[root@dbo1] ./rebar3 edoc


Generated by EDoc, Sep 7 2016, 09:32:13.