MCPcopy Index your code
hub / github.com/dadgar/onecache

github.com/dadgar/onecache @v0.1

Chat with this repo
repository ↗ · DeepWiki ↗ · release v0.1 ↗ · + Follow
313 symbols 1,061 edges 20 files 153 documented · 49%
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

OneCache

OneCache is a distributed key/value store that is accessible via the memcached protocol. OneCache nodes natively support clustering and best effort replication. Adding nodes into the cluster effectively increases the in-memory storage capability of the cache. Replication of keys minimizes the impact of a single node failure as requests will transparently be forwarded to the new key leader.

OneCache's architecture is built around the concept of a one-hop distributed hash table. Many DHT algorithms are designed for a very large number of members, such as bitorrent DHTs, and trade lookup efficiency for per-node storage and communication. However, OneCache is built for a much smaller cluster size (<100) and as such, every node holds the full state of the underlying consistent hash ring. This is advantageous because every node is capable of forwarding requests to the correct node, which is why it receives the term one-hop.

OneCache's name then becomes a play on its one-hop DHT and memcached protocol support.

Usage

Single Node

To start a single OneCache node listening on memcached's default port, simply run:

$> ./onecache

Clustered

To start a cluster of OneCache nodes on a single machine (for ease of getting started) we must bind the nodes to non-default ports to avoid collision. If clustering on different machines, the default ports can be used.

Start the first node in one terminal:

$> ./onecache -gossip_port=7946 -port=11211

In another, start the second and have it join. The output will show it added a peer node.

$> ./onecache -gossip_port=7947 -port=11212 -join="127.0.0.1:7946"
2016/01/18 12:04:30 [INFO] onecache: added peer node &{c3f48bd0-4106-43d4-9044-15cf552037f0 192.168.1.10 11211}

Usage

Standard memcached libraries can be used, which make OneCache an easy drop in replacement for memcached as code doesn't have to be changed. OneCache is also accessible via the terminal:

$> telnet 127.0.0.1 11211
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
set foo 0 0 12
hello, world
STORED

Extension points exported contracts — how you extend this code

Core symbols most depended-on inside this repo

Close
called by 25
onecache/pool.go
tearDownNodes
called by 24
onecache/test_util.go
connectedTestNodes
called by 23
onecache/test_util.go
Get
called by 19
ttlstore/ttlstore.go
sendMsg
called by 19
onecache/memcache.go
Destroy
called by 16
ttlstore/ttlstore.go
Set
called by 15
onecache/onecache_rpc.go
targetNode
called by 14
onecache/onecache_rpc.go

Shape

Method 184
Function 91
Struct 31
Interface 3
FuncType 2
TypeAlias 2

Languages

Go100%

Modules by API surface

onecache/replicator.go41 symbols
onecache/memcache_handlers.go41 symbols
ttlstore/ttlstore.go33 symbols
onecache/onecache_rpc.go25 symbols
onecache/replicator_test.go24 symbols
ttlstore/ttlstore_test.go17 symbols
ttlstore/ttl_heap.go17 symbols
onecache/ring.go17 symbols
onecache/pool.go17 symbols
onecache/onecache.go16 symbols
onecache/ring_test.go14 symbols
onecache/onecache_rpc_test.go10 symbols

For agents

$ claude mcp add onecache \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact