Kronos - Open Source distributed cache system
C# Other
Switch branches/tags
Nothing to show
Clone or download
Latest commit 6f4daad Jul 15, 2018

README.md

Kronos NuGet version

Kronos is distributed, in-memory cache system based on .NET Core. Client library is available by Nuget.

Build status

Windows Linux
Build status Build Status

Docker Image

Docker Stars

Kronos.Client - Installation

$ Install-Package Kronos.Client

Kronos.Client - Configuration file

Kronos client requires a cluster configuration file in JSON format. Example file is assigned to the package:

{
    "ClusterConfig": {
        "Servers": [
            {
                "Ip": "127.0.0.1",
                "Port": 44000
            },
            {
                "Ip": "127.0.0.1",
                "Port": 44001
            },
            {
                "Ip": "127.0.0.1",
                "Port": 44002
            }
        ]
    }
}

Kronos.Client - Usage

// initialize client
string configPath = "KronosConfig.json";
IKronosClient client = KronosClientFactory.CreateClient(configPath);

// create a key, package and expiry date
string key = "key";
byte[] packageToCache = Encoding.UTF8.GetBytes("Lorem ipsum");
DateTime expiryDate = DateTime.UtcNow.AddDays(5);

// insert package to server
await client.InsertAsync(key, packageToCache, expiryDate);

// get package from server
byte[] cachedValues = await client.GetAsync(key);

// check if storage contains given key
bool contains  = await client.ContainsAsync(key);

// count number of elements in the storage
int number  = await client.CountAsync();

// Optionally you can delete object from cache using Delete command
await client.DeleteAsync(key);

// or flush all storage
await client.ClearAsync();

Server initialization using docker image

To start server using docker, login as a sudo and type:

docker run -td -p 44000:44000 lukaszpyrzyk/kronos 44000
docker run -td -p 44001:44001 lukaszpyrzyk/kronos 44001
docker run -td -p 44002:44002 lukaszpyrzyk/kronos 44002

where:

  • t - allocate a pseudo-tty
  • d - start a container in detached mode
  • p - assign public port 44000 to internal 44000
  • lukaszpyrzyk/kronos - name of the image, https://hub.docker.com/r/lukaszpyrzyk/kronos/
  • 44000 - number of internal port, value passed to the Kronos

Full documentation is available on the docker reference page

Cluster initialization using docker-compose

Create a docker-compose.yml file with cluster configuration:

kronos-a:
  image: lukaszpyrzyk/kronos
  command: "44000"
  ports:
    - 44000:44000

kronos-b:
  image: lukaszpyrzyk/kronos
  command: "44001"
  ports:
    - 44001:44001

kronos-c:
  image: lukaszpyrzyk/kronos
  command: "44002"
  ports:
    - 44002:44002

Save the file and run command:

docker-compose up -d

where

  • d - start a containers in detached mode

This command will create and start three Kronos Severs.

Building own docker image

If you don't want to use my docker image, you can build your own. Clone repository and type:

docker build -t kronos .

University

I am a student of Opole University Of technology and this is my Engineering Thesis.

License

MIT