score:0
Try the JedisPool. the implementation of redis.
You need to disable the default cache module before using the redis cache. play.modules.disabled = ["play.api.cache.EhCacheModule"]
In the build.sbt.
"com.typesafe.play.modules" %% "play-modules-redis" % "2.4.0",
score:0
You can use the cache in any class of your project, I used the following code in my java project:
public class ProductServiceImpl implements ProductService {
private final WSClient ws;
private UserService userService;
private CacheApi cache;
@Inject
public ProductServiceImpl(WSClient ws) {
this.ws = ws;
}
@Inject
public void setCache(CacheApi cache) {
this.cache = cache;
}
@Inject
public void setUserService(UserService userService) {
this.userService = userService;
}
}
But in Scala I assume that you can do something like this:
import javax.inject._
import play.api.cache._
class Model @Inject() (cache: CacheApi) {
// ...
}
Note:
The @Inject annotation can be used on fields or on constructors
More info about how to use the @Inject annotation on play scala: https://www.playframework.com/documentation/2.4.x/ScalaDependencyInjection#Declaring-dependencies
Source: stackoverflow.com
Related Query
- Unable to use caching at model level
- Unable to use for comprehension to map over List within Future
- Use of lazy val for caching string representation
- Unable to import ChannelSftp.LsEntry from Jsch when I use it in Scala code, why?
- How to use members with default (package) or private access level in REPL?
- High level of what I will need to do to port ReactiveMongo scala to use cats effects?
- Understanding the scala substitution model through the use of sumInts method
- Spark: Caching an RDD/DF for use across multiple programs
- Cannot use futures in scala.js - Rhino was unable to load Scala.js class
- Unable to use Apache Commons CLI Option.builder() in Scala
- Why spark blas use f2jBLAS instead of native BLAS for level 1 routines?
- Unable to use activator on my Mac - get a timeout exception when I try and make an app from template
- Writing scala-js frontend framework with server-side rendering. Unable to use scala-js-dom on server
- Unable to use scala's repl :javap to look at trait companion object
- How to use Spark MlLib/Pipelines to build 1 model per each user
- Unable to use ScalaCheck with Scala IDE for Eclipse
- Unable to use Scala and Spring MVC 3 to return JSON
- How does scala's actor model make use of C threads and native system threads?
- Scala 2.12: Unable to use unapply in extractor object
- Unable to use Mongo Scala driver with case classes
- Spark SQL: Unable to use aggregate within a window function
- How to use Weka model on Spark
- ArrayList in Scala with Gistlabs Mechanize. Unable to use foreach
- Unable to use java code in scala
- Unable to save XGBoost model with spark
- Unable to run transform in Mleap runtime from Spark model
- unable to assign a value in getOrElse path of Option if I use print statement in getOrElse
- unable to use non lagom based static project services with service-locator-dns library
- What data structure would you use to model a Blockchain?
- Unable to use collectAsMap() in scala code
More Query from same tag
- JsonProperty annotation does not work for Json parsing in Scala (Jackson/Jerkson)
- add scala code to java file
- FP growth model in spark
- How do you enable a postfix operator in scala?
- scala get response from REST service
- Want to parse a file and reformat it to create a pairRDD in Spark through Scala
- Error in scala IDE
- Issue importing Akka packages
- Class Type T - Explained
- How to create a method which invokes another service and return a Future?
- Test API REST SCALA
- Are scala case patterns first class?
- Reading Lines of Input into Array in Scala?
- What to use instead of symbols in scalatest?
- How to obtain coefficient values from Spark-MLlib Linear Regression model (Scala)?
- How to construct a Scala map and pass as arg into a Scala constructor in Python interpreter?
- copy 2-dimensional Array
- How to use Argonaut to decode poorly structured JSON where key name is meaningful
- unable to run web-app developed using scalatra scala
- java.lang.ClassNotFoundException: breeze.generic.UFunc$UImpl2 when using Breeze DenseVector
- Group pair of elements in a List
- Scala Date Format issue
- Cache and Query a Dataset In Parallel Using Spark
- How to query the closest item to timestamp in Dynamo DB with Scala
- How to go from an functor over an effect to an effect over the functor?
- How to append to a list variable in session
- Regular expressions on Scala - Searching from the beginning of String
- What parameters do I pass to 'filter' function in Scala
- Get http headers with akka routing dsl
- Implement trait methods using subclasses' types