File tree Expand file tree Collapse file tree 1 file changed +4
-14
lines changed
Expand file tree Collapse file tree 1 file changed +4
-14
lines changed Original file line number Diff line number Diff line change @@ -32,30 +32,20 @@ val data = Map(
3232``` scala
3333object CacheImplicits {
3434
35- implicit lazy val testEntityCache : GenericCache .Aux [String , TestEntity ] = // String:缓存key,TestEntity:缓存值
36- GenericCache [String , TestEntity ](CacheType .Lru ()) // 缓存类型 lru
37-
38- // implicit lazy val testEntityAsyncCache: GenericCache.Aux[String, TestEntity] = // String:缓存key,TestEntity:缓存值
39- // GenericCache[String, TestEntity](CacheType.Lru(), ExecutionContext.Implicits.global) // Future cache
35+ implicit lazy val testEntityAsyncCache : GenericCache .Aux [String , TestEntity ] = // String:缓存key,TestEntity:缓存值
36+ GenericCache [String , TestEntity ](CacheType .Lru (), ExecutionContext .Implicits .global) // Future cache
4037}
4138```
4239
43402 . 初始化-获取缓存
4441``` scala
4542import CacheImplicits ._
4643
47- val cache : CacheRef [String , TestEntity , Identity ] = Cache .getSyncCache[TestEntity ]
48- // Future
49- // val asyncCache: CacheRef[String, TestEntity, Future] = Cache.getAsyncCache[TestEntity]
44+ val asyncCache = Cache [String , TestEntity ]
5045cache.init(data)
5146```
5247
53483 . 从缓存中取数据
5449``` scala
55- val result : Option [TestEntity ] = cache.getT(" etc" ) // 特殊key需要传CacheKeyBuilder
56- ```
57-
58- 4 . 从缓存中只取数据的一个` key ` 字段
59- ``` scala
60- val keyOpt : Option [String ] = cache.getTField(" etc" , CaseClassField [TestEntity ](_.key))
50+ val result : Future [Option [TestEntity ]] = cache.getT(" etc" ) // 特殊key需要传CacheKeyBuilder
6151```
You can’t perform that action at this time.
0 commit comments