Cache annotations in playframework with guice

264 views Asked by At

I'm trying to plugin cache-annotations-ri-guice as mentioned here. I found a description. But it doesn't work. My test project looks like

public class HomeController extends Controller {

public Result index() {
    return ok(getString("qwe"));
}

@CacheResult
private String getString(String str) {
    Random r = new Random();
    return "HelloWorld " + str + r.nextInt();
}
}

This call every time returns different values.

build.sbt:

name := """myann"""
organization := "com.example"

version := "1.0-SNAPSHOT"

lazy val root = (project in file(".")).enablePlugins(PlayJava, PlayNettyServer, LauncherJarPlugin)
  .disablePlugins(PlayAkkaHttpServer)
  .settings(libraryDependencies ++= Seq(
     guice,
    jcache,
    ehcache,
    "org.jsr107.ri" % "cache-annotations-ri-guice" % "1.0.0"
  ))

scalaVersion := "2.12.2"

Module.java:

public class Module extends AbstractModule {

@Override
public void configure() {
    install(new CacheAnnotationsModule());
}
}

My environment: addSbtPlugin("com.typesafe.play" % "sbt-plugin" % "2.6.3") sbt.version=0.13.15 How to make it working regularly?

1

There are 1 answers

0
pswrdf On BEST ANSWER

This annotations doesn't work for private methods.