Giter Club home page Giter Club logo

play-redis's Introduction

Redis Cache Module for Play Framework

Built over the Jedis connector and Akka serialization for maximum flexibility. One of the main goal is to provide a consistent implementation over multiple Play framework versions to allow interoperability.

Features

  • Akka serialization for pluggable serialization protocols.
  • Compression of larger values to reduce latency.
  • 2-tier cache system, recent keys are kept in a local cache.

Usage

Add this GitHub maven package repository to your build: willtrnr/maven-repo

Then add the dependency with the correct Play major and minor suffix:

libraryDependencies += "net.archwill.play" %% "play-redis" % "1.0.5.play26"

Check for the latest version in the download badge above, also use the version suffix matching your Play's major and minor release. Play version 2.4.x to 2.7.x are fully supported.

Then enable the module in your configuration, while disabling Ehcache:

play.modules.disabled += "play.api.cache.EhCacheModule"
play.modules.enabled += "net.archwill.play.redis.RedisModule"

Add the proper configuration to connect to your Redis server, minimally this should include the host and port to use:

redis {
  host = "localhost"
  port = 6379
}

Check out the other possible knobs and defaults in reference.conf.

Serialization

Objects will be serialized using Akka Serialization making it possible to use Kryo or any other saner alternative than Java serialization. Read the Akka documentation for how to set this up.

Local Cache

This plugin also makes use of a local cache to speed up lookups for recent keys. When retrofitting caching in a legacy system making inneficient use of database requests with duplicated queries this can greatly help the response time.

A Redis Pub-Sub channel is used to communicate the invalidations, which may introduce a slight delay between when a key is changed and when every application instance is aware of it. Depending on how your application makes use of the cache this may be a source of issues.

If needed, disabled it by setting the redis.local-cache.max-size configuration key to 0. You may also want to tweak that value depending on the number of unique keys used and the heap memory available.

Some scenarios where it could be desirable to disable the local cache include:

  • The keys used are vastly different with each request
  • Your application is sensitive to data freshness
  • Keys are not requested more than once per request
  • Cache keys are changing extremely often

License

MIT

play-redis's People

Contributors

willtrnr avatar

Stargazers

Louis-Marie Marcadon 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.