MSCache is a distributed key-value cache implemented in Go, designed to facilitate a distributed caching system where server nodes communicate with each other using the TCP protocol. The client can connect to any node within the cluster using TCP for interactions.
- Go 1.20
Ensure that you have Go installed on your system.
Clone the repository:
git clone <https://github.com/MSSkowron/MSCache>
Navigate to the project directory:
cd MSCache
To launch a leader node, use the following command:
go run ./cmd/mscache/main.go --listenaddr <address>
For example:
go run ./cmd/mscache/main.go --listenaddr 127.0.0.1:5000
To launch a follower node, use the following command:
go run ./cmd/mscache/main.go --listenaddr <address> --leaderaddr <address>
For example:
go run ./cmd/mscache/main.go --listenaddr 127.0.0.1:5001 --leaderaddr 127.0.0.1:5000
Note: Each node must have a unique listen address.
Install the application globally using go install
:
go install github.com/MSSkowron/MSCache/cmd/mscache@latest
With this, the mscache command becomes accessible globally. Run it using:
mscache --listenaddr <address> --leaderaddr <address>
To interact with the server, you can utilize the Client
structure defined in /client/client.go
. This structure provides methods to communicate with the cache server. Set
, Delete
, and GET
methods are exclusively available with the leader server, while only the GET
method is presently available with follower servers.
An example client's code is provided here. You can run it specifying the server node's address with the serveraddr
flag.
go run ./examples/client/main.go --serveraddr <address>
For example:
go run ./examples/client/main.go --serveraddr 127.0.0.1:5000
The project is available as open source under the terms of the MIT License.