Skip to content
This repository has been archived by the owner on Feb 9, 2019. It is now read-only.

Redis play 2.4 #148

Merged
merged 18 commits into from
Jun 24, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
12 changes: 11 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,16 @@
jdk: openjdk6
jdk:
- openjdk6
- oraclejdk8
language: scala
env:
- PROJECT=statsd
- PROJECT=redis
script: cd util && sbt +publish-local && cd ../$PROJECT && sbt +test
matrix:
exclude:
- jdk: openjdk6
env: PROJECT=redis
- jdk: oraclejdk8
env: PROJECT=statsd
services:
- redis-server
40 changes: 35 additions & 5 deletions redis/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ val o = play.api.cache.Cache.getAs[String]("mykey")


#### Allows direct access to Jedis and Sedis:

play = 2.3.x:
```java
//java
import com.typesafe.plugin.RedisPlugin;
Expand All @@ -66,6 +66,19 @@ pool.withJedisClient { client =>
Option[String] single = Dress.up(client).get("single")
}
```
play = 2.4.x:
Because the underlying Sedis Pool was injected for the cache module to use, you can just inject the sedis Pool yourself, something like this:

```scala
//scala
import javax.inject.Inject
import org.sedis.Pool

class TryIt @Inject()(sedisPool: Pool) extends Controller {
val directValue: String = sedisPool.withJedisClient(client => client.get("someKey"))
}
```

# How to install

* add
Expand All @@ -82,10 +95,27 @@ play = 2.3.x:

* 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
```
```
#conf/application.conf
ehcacheplugin=disabled
```

play = 2.4.x:
```"com.typesafe" %% "play-modules-redis" % "2.4.0"``` to your dependencies

* The default cache module (EhCache) will be used for all non-named cache UNLESS this module (RedisModule) is the only cache module that was loaded. If this module is the only cache module being loaded, it will work as expected on named and non-named cache. To disable the default cache module so that this Redis Module can be the default cache you must put this in your configuration:

```
play.modules.disabled = ["play.api.cache.EhCacheModule"]
```

* This module supports play 2.4 NamedCaches through key namespacing on a single Sedis pool. To add additional namepsaces besides the default (play), the configuration would look like such:

```
play.cache.redis.bindCaches = ["db-cache", "user-cache", "session-cache"]
```



# Sample

Expand Down
23 changes: 12 additions & 11 deletions redis/build.sbt
Original file line number Diff line number Diff line change
@@ -1,26 +1,27 @@
import scala.Some
name := "play-modules-redis"

name := "play-plugins-redis"
organization := "com.typesafe.play.modules"

organization := "com.typesafe.play.plugins"

version := "2.3.1"
version := "2.4.0"

scalaVersion := "2.11.2"

crossScalaVersions := Seq("2.11.2", "2.10.4")

libraryDependencies ++= Seq(
"com.typesafe.play" %% "play" % "2.3.0" % "provided",
"com.typesafe.play" %% "play" % "2.4.0" % "provided",
"com.typesafe.play" %% "play-cache" % "2.4.0",
"biz.source_code" % "base64coder" % "2010-12-19",
"com.typesafe.play" %% "play-cache" % "2.3.0",
"com.typesafe.play.plugins" %% "play-plugins-util" % "2.3.0",
"org.sedis" %% "sedis" % "1.2.2"
"org.sedis" %% "sedis" % "1.2.2",
"com.typesafe.play" %% "play-test" % "2.4.0" % "test",
"com.typesafe.play" %% "play-specs2" % "2.4.0" % "test",
"org.specs2" %% "specs2-core" % "3.3.1" % "test"
)

resolvers ++= Seq(
"pk11 repo" at "http://pk11-scratch.googlecode.com/svn/trunk",
"Typesafe repository" at "http://repo.typesafe.com/typesafe/releases/"
"Typesafe repository" at "http://repo.typesafe.com/typesafe/releases/",
"Scalaz Bintray Repo" at "http://dl.bintray.com/scalaz/releases"
)

publishTo <<= (version) { version: String =>
Expand All @@ -29,6 +30,6 @@ publishTo <<= (version) { version: String =>
else Some("releases" at nexus + "maven-releases/")
}

javacOptions ++= Seq("-source", "1.6", "-target", "1.6", "-Xlint:unchecked", "-encoding", "UTF-8")
javacOptions ++= Seq("-source", "1.8", "-target", "1.8", "-Xlint:unchecked", "-encoding", "UTF-8")

scalacOptions += "-deprecation"
2 changes: 1 addition & 1 deletion redis/project/build.properties
Original file line number Diff line number Diff line change
@@ -1 +1 @@
sbt.version=0.13.5
sbt.version=0.13.8
21 changes: 0 additions & 21 deletions redis/sample/app/Global.java

This file was deleted.

22 changes: 0 additions & 22 deletions redis/sample/app/controllers/Application.java

This file was deleted.

3 changes: 0 additions & 3 deletions redis/sample/app/views/index.scala.html

This file was deleted.

15 changes: 0 additions & 15 deletions redis/sample/app/views/main.scala.html

This file was deleted.

58 changes: 0 additions & 58 deletions redis/sample/conf/application.conf

This file was deleted.

1 change: 0 additions & 1 deletion redis/sample/conf/play.plugins

This file was deleted.

9 changes: 0 additions & 9 deletions redis/sample/conf/routes

This file was deleted.

18 changes: 0 additions & 18 deletions redis/sample/project/Build.scala

This file was deleted.

1 change: 0 additions & 1 deletion redis/sample/project/build.properties

This file was deleted.

8 changes: 0 additions & 8 deletions redis/sample/project/plugins.sbt

This file was deleted.

Binary file removed redis/sample/public/images/favicon.png
Binary file not shown.
4 changes: 0 additions & 4 deletions redis/sample/public/javascripts/jquery-1.7.1.min.js

This file was deleted.

Empty file.
16 changes: 16 additions & 0 deletions redis/src/main/resources/reference.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
play {

modules {
enabled += "com.typesafe.play.redis.RedisModule"
}

cache {
# The name of the default cache to use in redis
defaultCache = "play"

redis {
# The caches to bind
bindCaches = []
}
}
}