GitXplorerGitXplorer
b

play-plugins-redis

public
0 stars
0 forks
0 issues

Commits

List of commits on branch master.
Unverified
48019d342d7f6487d3b0ec9e7a055e4216879e58

use play-plugin-util 2.1.0 for the time being

committed 12 years ago
Unverified
eb7c5328287ea310fce3b760a94837ef822a8bf8

Build for play2.1.1

bbaloo committed 12 years ago
Unverified
27812f5bfeae0781d3866965ebe70e32affcbc55

Initial commit

committed 12 years ago

README

The README file for this repository.

forked from https://github.com/typesafehub/play-plugins/tree/master/redis

Redis Plugin

This plugin provides support for Redis using the best Java driver Jedis and the corresponding Scala wrapper Sedis. Also implements play's internal [Caching] (https://github.com/playframework/Play20/blob/master/framework/src/play/src/main/scala/play/api/cache/Cache.scala#L9) interface

Features

  • Provides a Redis-based Cache API (supported types: String, Int, Long, Boolean and Serializable) ie.
//java
String f = (String) play.cache.Cache.get("mykey");

and

//scala
val o = play.api.cache.Cache.getAs[String]("mykey")
  • configurable ( variables: redis.host, redis.port, redis.timeout, redis.password, defaults are localhost, 6379, 2000, nul )

  • Allows direct access to Jedis and Sedis:

//java
import com.typesafe.plugin.RedisPlugin;
import redis.clients.jedis.*;

Jedis j = play.Play.application().plugin(RedisPlugin.class).jedisPool().getResource();

try {
  /// ... do stuff here 
  j.set("foo", "bar");
} finally {
  play.Play.application().plugin(RedisPlugin.class).jedisPool().returnResource(j);
}  
//scala
import play.api.Play.current
import com.typesafe.plugin.RedisPlugin

val pool = use[RedisPlugin].sedisPool
pool.withJedisClient { client =>
  Option[String] single = Dress.up(client).get("single")
}

How to install

  • add

play 2.0.x: "com.typesafe" %% "play-plugins-redis" % "2.0.4" to your dependencies

  • create a file called play.plugins in your app/conf directory

  • add 550:com.typesafe.plugin.RedisPlugin

  • while this plugin is going to be loaded before the default cache implementation, it's a good practice to disable the overwritten plugin:

#conf/application.conf
ehcacheplugin=disabled

Sample

for an example, see the bundled sample app

Licence

This software is licensed under the Apache 2 license, quoted below.

Copyright 2012 Typesafe (http://www.typesafe.com).

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this project except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0.

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.