Skip to content

arazmj/gerdu

Repository files navigation

Build Release Go Report Card codecov Maintainability GoDoc License codebeat badge Scrutinizer Code Quality

Gerdu

About

Gerdu is a key-value in-memory database server written in Go programming language. Currently, it supports two eviction policy LFU and LRU. It also supports for weak reference type of cache where the cache consumes as much memory as the garbage collector allows it to use.

You can enable gRPC, HTTP and memcached and enjoy taking advantage of both protocols simultaneously.

Build

$go build -v

Usage

Usage of gerdu:
  -capacity string
        The size of cache, once cache reached this capacity old values will evicted.
        Specify a numerical value followed by one of the following units (not case sensitive)
        K or KB: Kilobytes
        M or MB: Megabytes
        G or GB: Gigabytes
        T or TB: Terabytes (default "64MB")
  -cert string
        SSL certificate public key
  -grpcport int
        the grpc server port number (default 8081)
  -host string
        The host that server listens (default "127.0.0.1")
  -httpport int
        the http server port number (default 8080)
  -key string
        SSL certificate private key
  -log string
        log level can be any of values of 'panic', 'fatal', 'error', 'warn', 'info', 'debug', 'trace' (default "error")
  -mcdport int
        the memcached server port number (default 11211)
  -protocols string
        protocol 'grpc', 'http' or 'mcd' (memcached), multiple values can be selected separated by comma (default "http")
  -type string
        type of cache, lru or lfu, weak (default "lru")

Example

Example of usage: To insert or update or delete a key

$./gerdu --protocols grpc,http,mcd # runs gerdu in all modes 
$curl --request PUT --data '1' http://localhost:8080/cache/1
$curl --request PUT --data '2' http://localhost:8080/cache/2
$curl --request PUT --data '3' http://localhost:8080/cache/3
$curl --request PUT --data 'some new value' http://localhost:8080/cache/3
$curl --request DELETE http://localhost:8080/cache/3 # Delete key 3
$curl --request GET localhost:8080/cache/3 # Not found 404

To retrieve the key

$curl --request GET localhost:8080/cache/3

Telemetry

Prometheus metrics

$curl --request GET localhost:8080/metrics

Sample applications

Sample applications are available in: