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 all protocols simultaneously.
go build -v
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 of usage: To insert or update or delete a key
foo@bar:~$ ./gerdu --protocols=http,grpc,mcd
INFO[0000] Gerdu started listening HTTP on 127.0.0.1:8080
INFO[0000] Gerdu started memcached server on 127.0.0.1:11211
INFO[0000] Gerdu started listening gRPC on 127.0.0.1:8081
foo@bar:~$ curl --request PUT --data '1' http://localhost:8080/cache/1
foo@bar:~$ curl --request GET --data '1' http://localhost:8080/cache/1
1
foo@bar:~$ curl --request PUT --data '2' http://localhost:8080/cache/2
foo@bar:~$ curl --request PUT --data '3' http://localhost:8080/cache/3
foo@bar:~$ curl --request PUT --data 'some new value' http://localhost:8080/cache/3
foo@bar:~$ curl --request DELETE http://localhost:8080/cache/3 # Delete key 3
foo@bar:~$ curl --request GET localhost:8080/cache/3 # Not found 404
To retrieve the key
foo@bar:~$ curl --request GET localhost:8080/cache/3
Prometheus metrics
foo@bar:~$ curl --request GET localhost:8080/metrics
...
# HELP gerdu_adds_total The total number of new added nodes
# TYPE gerdu_adds_total counter
gerdu_adds_total 52152
# HELP gerdu_deletes_total The total number of deletes nodes
# TYPE gerdu_deletes_total counter
gerdu_deletes_total 23
# HELP gerdu_hits_total The total number of cache hits
# TYPE gerdu_hits_total counter
gerdu_hits_total 1563
# HELP gerdu_misses_total The total number of missed cache hits
# TYPE gerdu_misses_total counter
gerdu_misses_total 16
...
Sample applications are available in:
- C# (HTTP, gRPC)
- C (HTTP, gRPC)
- Dart (HTTP)
- Elixir (HTTP)
- Erlang (HTTP)
- GoLang (HTTP, gRPC, memcached)
- Groovy (HTTP)
- Haskell (HTTP)
- Java (HTTP, gRPC)
- Kotlin (HTTP)
- NodeJS (HTTP)
- Objective-C (HTTP, gRPC)
- Perl (HTTP)
- PHP (HTTP)
- Python (HTTP, gRPC, memcached)
- R (HTTP)
- Ruby (HTTP, gRPC)
- Rust (HTTP, gRPC)
- Scala (HTTP)
- Swift (HTTP)