Documentation

You are viewing the documentation for the 2.6.0-M4 development release. The latest stable release series is 3.0.x.

§Cache APIs Migration

§Removed APIs

The deprecated Java class play.cache.Cache was removed and you now must inject an play.cache.SyncCacheApi or play.cache.AsyncCacheApi.

§New Sync and Async Cache APIs

The Cache API has been rewritten to have a synchronous and an asynchronous version. The old APIs will still work but they are now deprecated.

§Java API

The interface play.cache.CacheApi is now deprecated and should be replaced by play.cache.SyncCacheApi or play.cache.AsyncCacheApi.

To use, play.cache.SyncCacheApi just inject it:

public class SomeController extends Controller {

    private SyncCacheApi cacheApi;

    @Inject
    public SomeController(SyncCacheApi cacheApi) {
        this.cacheApi = cacheApi;
    }
}

And then there is the asynchronous version of the API:

public class SomeController extends Controller {

    private AsyncCacheApi cacheApi;

    @Inject
    public SomeController(AsyncCacheApi cacheApi) {
        this.cacheApi = cacheApi;
    }
}

See more details about how to use both APIs at specific documentation.

§Scala API

The trait play.api.cache.CacheApi is now deprecated and should be replaced by play.api.cache.SyncCacheApi or play.api.cache.AsyncCacheApi.

To use play.api.cache.SyncCacheApi, just inject it:

class Application @Inject() (cache: SyncCacheApi) extends Controller {

}

Basically the same for play.api.cache.AsyncCacheApi:

class Application @Inject() (cache: AsyncCacheApi) extends Controller {

}

See more details about how to use both APIs at specific documentation.

Next: JPA Migration