-
Notifications
You must be signed in to change notification settings - Fork 43
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Migrated documentation of version 2.0.2 from wiki
- Loading branch information
1 parent
94e85b4
commit 4134c52
Showing
9 changed files
with
662 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,4 @@ | ||
# Compilation output | ||
doc/ | ||
bin/ | ||
lib/ | ||
out/ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
# Integration Guide | ||
|
||
The library comes with the support of both compile-time and runtime-time dependency injection. | ||
Although the use of runtime-time injection is preferred, both options are equal and fully implemented. | ||
|
||
## Runtime-time Dependency Injection | ||
|
||
You **must enable the redis cache module** in `application.conf`: | ||
|
||
``` | ||
# enable redis cache module | ||
play.modules.enabled += "play.api.cache.redis.RedisCacheModule" | ||
``` | ||
|
||
It will bind all required components and make them available through runtime DI according to the configuration. | ||
|
||
## Compile-time Dependency Injection | ||
|
||
To use compile-time DI, mix `play.api.cache.redis.RedisCacheComponents` | ||
into your `BuiltInComponentsFromContext` subclass. It exposes `cacheApi` method | ||
accepting a redis instance (or just cache name, if configured) and returns an instance | ||
of `RedisCaches` encapsulating all available APIs for this particular cache. Then you | ||
can access and expose them yourself. Next, it provides a few methods to override and | ||
provide customized configuration. For more details, see directly `RedisCacheComponents` source. | ||
|
||
``` | ||
// 'play' is the name of the named cache | ||
// (play is default name of the default cache) | ||
// | ||
// the 'play' literal is implicitly converted into | ||
// the instance but has to be configured in 'application.conf' | ||
val playCache: RedisCaches = cacheApi( "play" ) | ||
// expose `play.api.cache.redis.CacheAsyncApi` | ||
val asynchronousRedis = playCache.async | ||
``` |
Oops, something went wrong.