Module mod_tkvstore

Simple (type,key)/value store.

Copyright © 2010 Marc Worrell

Behaviours: gen_server.

Authors: Marc Worrell (marc@worrell.nl).

Description

Simple (type,key)/value store. Stores data in the store with minimal latency and (local) serialization of get/put requests.

Function Index

code_change/3Convert process state when code is changed.
handle_call/3Fetch persistent data, first check the data dict that is still being written.
handle_cast/2Put request, copy to the writer, keep a local copy of the data.
handle_info/2Handling all non call/cast messages.
init/1Initiates the server.
pid_observe_tkvstore_delete/3Delete the persistent data of a type/key.
pid_observe_tkvstore_get/3Fetch the persistent data of a type/key.
pid_observe_tkvstore_put/3Do a put in the persistent store, replace existing key/value.
start_link/0Starts the server.
start_link/1
terminate/2This function is called by a gen_server when it is about to terminate.
writer_loop/2Simple writer loop, started as a process.

Function Details

code_change/3

code_change(OldVsn, State, Extra) -> {ok, NewState}

Convert process state when code is changed

handle_call/3

handle_call(Tkvstore_get::Request, From, State) -> {reply, Reply, State} | {reply, Reply, State, Timeout} | {noreply, State} | {noreply, State, Timeout} | {stop, Reason, Reply, State} | {stop, Reason, State}

Fetch persistent data, first check the data dict that is still being written

handle_cast/2

handle_cast(Tkvstore_put::Msg, State) -> {noreply, State} | {noreply, State, Timeout} | {stop, Reason, State}

Put request, copy to the writer, keep a local copy of the data

handle_info/2

handle_info(Info, State) -> {noreply, State} | {noreply, State, Timeout} | {stop, Reason, State}

Handling all non call/cast messages

init/1

init(Args) -> {ok, State} | {ok, State, Timeout} | ignore | {stop, Reason}

Initiates the server.

pid_observe_tkvstore_delete/3

pid_observe_tkvstore_delete(Pid, Tkvstore_delete, Context) -> any()

Delete the persistent data of a type/key

pid_observe_tkvstore_get/3

pid_observe_tkvstore_get(Pid, Tkvstore_get, Context) -> any()

Fetch the persistent data of a type/key

pid_observe_tkvstore_put/3

pid_observe_tkvstore_put(Pid, Tkvstore_put, Context) -> any()

Do a put in the persistent store, replace existing key/value

start_link/0

start_link() -> {ok, Pid} | ignore | {error, Error}

Starts the server

start_link/1

start_link(Args) -> any()

terminate/2

terminate(Reason, State) -> void()

This function is called by a gen_server when it is about to terminate. It should be the opposite of Module:init/1 and do any necessary cleaning up. When it returns, the gen_server terminates with Reason. The return value is ignored.

writer_loop/2

writer_loop(KVStorePid, Context) -> any()

Simple writer loop, started as a process


Generated by EDoc