Giter Site home page Giter Site logo

redis-proxy's Introduction

Redis Proxy

The Redis proxy is implemented in Scala (version 2.13) using the Akka toolkit and scala-redis.

Running and building

To run tests execute: make test

This will automatically start a Redis instance used for integration testing.

To run the proxy the Redis proxy execute: make run

Configuration

The proxy can be configured through environment variables that are stored in the .env file:

PORT=9090
CACHE_SIZE=1000
MAX_CACHE_LIFETIME=100000	# milliseconds
REDIS_HOST="redis"
REDIS_PORT=6379

Or by changing the application.conf file in the src/main/resources directory. application.conf contains additional settings, for example to specify the maximum number of concurrently connected clients.

Architecture and documentation

A generated API documentation can be found in the api/ directory and viewed by opening index.html.

Architecture

The following figure shows an overview of the different components the system is composed of:

Architecture

Clients can connect to RedisProxyService and send HTTP requests. RedisProxyService will process requests concurrently by making use of its actor model. Depending on the request type or whether the accessed entry is cached, RedisProxyService accesses the LruCache or the backing Redis instance it is connected to via a RedisConnector.

The LruCache implements the generic Cache trait and could be easily replaced by another cache implementation. LruCache also allows concurrent access by multiple clients and is thread-safe by using ConcurrentLinkedHashMap for its internal storage. The LruCache has a maximum size that can be configured and entries have a configurable expiration time. When accessing the cache, the expiration time for the accessed entry gets updated.

API

Supported operations:

  • Access value: GET /GET/<key>
  • Store key-value pair: POST /SET
    • Request body (JSON): {"key": <key>, "value": "<value>"}
      • Currently <value> needs to be a string
  • Remove key-value pair from cache and Redis: DELETE /DEL/<key>

Used libraries and toolkits

  • akka-actor: Akka toolkit, provides the actor system and support for creating HTTP servers.
  • config: Library that allows usage of external configuration files. Configuration files are stored in the src/main/resources directory and can be easily accessed using this library.
  • akka-testkit: Testkit required for testing Akka actors.
  • scalatest: Testing framework for Scala.
  • akka-http-core and akka-http: Akka framework for creating HTTP servers.
  • concurrentlinkedhashmap-lru: A high performance version of java.util.LinkedHashMap for use as a software cache.
  • joda-time: Date and time classes.
  • redisclient: Redis client library for Scala.

redis-proxy's People

Contributors

scholtzan avatar

Watchers

James Cloos 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.