Giter Site home page Giter Site logo

mc's Introduction

MC

MC - short for Memory Cache - is a simple distributed caching server for learning purpose.

Features

  • In memory LRU cache
  • RPC transport
  • Cluster
  • Command line client
  • Go client

So far, MC has only get, add and remove of caching and a Consistent Hash Algorithm will be considered to use for the scalability in the future.

Usage

Install

go get github.com/mivinci/mc

Or (not available yet)

docker pull mivinci/mc

Or download the pre-build version for macOS or Windows.

Run

mc can be run either a server or a client.

Run an MC server.

mc -server

By default, MC chooses 127.0.0.1:8000 to serve on, or you can decide the address by providing a -address parameter.

mc -server -address 127.0.0.1:8001

for short

mc -server -address :8001

You can customize the maximum caching size for a single MC server.

mc -server -c 128

Run an MC client.

mc -client

Also, the MC client chooses 127.0.0.1:8000 to dial during usage. You can provide an -address parameter to the MC client to communicate with a different address.

Use Cluster

Once you have run multiple MC servers, you can communicate with them simply by using the MC client with multiple addresses seperated by commas.

mc -client -address 1.1.1.1:8000,1.1.1.2:8001,1.1.1.3:8002

The MC command line client will lead you to an interface like this.

$ mc -client
MC v1.0.0, press [ctrl c] to exit.
127.0.0.1:8000> get name
XJJ
127.0.0.1:8000> remove name
127.0.0.1:8000> get name
nil

Go Client

import "github.com/mivinci/mc"

Add

r := mc.Add("name", []byte("XJJ"))

Get

r := mc.Get("name")

Remove

r := mc.Remove("name")

Cluster

client := mc.NewClient("1.1.1.1:8000", "1.1.1.2:8001", "1.1.1.3:8000")
r := client.Get("name")
...

About

Thanks to the projects and videos below for the inspiration.

mc's People

Contributors

mivinci avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.