This repository has been archived by the owner on Mar 28, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Introduced Services layer and improved episode filtering logic
- Loading branch information
Showing
10 changed files
with
114 additions
and
33 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
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
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
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,23 @@ | ||
package fr.ziedelth.services | ||
|
||
import com.google.common.cache.CacheBuilder | ||
import com.google.common.cache.CacheLoader | ||
import fr.ziedelth.entities.Country | ||
import fr.ziedelth.repositories.CountryRepository | ||
|
||
class CountryService(val repository: CountryRepository) { | ||
private val loadingCache = CacheBuilder.newBuilder() | ||
.build(object : CacheLoader<String, List<Country>>() { | ||
override fun load(key: String): List<Country> { | ||
println("Updating country cache") | ||
return repository.getAll() | ||
} | ||
}) | ||
|
||
fun invalidateAll() { | ||
println("Invalidate all country cache") | ||
loadingCache.invalidateAll() | ||
} | ||
|
||
fun getAll(): List<Country> = loadingCache.getUnchecked("") | ||
} |
23 changes: 23 additions & 0 deletions
23
src/main/kotlin/fr/ziedelth/services/EpisodeTypeService.kt
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,23 @@ | ||
package fr.ziedelth.services | ||
|
||
import com.google.common.cache.CacheBuilder | ||
import com.google.common.cache.CacheLoader | ||
import fr.ziedelth.entities.EpisodeType | ||
import fr.ziedelth.repositories.EpisodeTypeRepository | ||
|
||
class EpisodeTypeService(val repository: EpisodeTypeRepository) { | ||
private val loadingCache = CacheBuilder.newBuilder() | ||
.build(object : CacheLoader<String, List<EpisodeType>>() { | ||
override fun load(key: String): List<EpisodeType> { | ||
println("Updating episode type cache") | ||
return repository.getAll() | ||
} | ||
}) | ||
|
||
fun invalidateAll() { | ||
println("Invalidate all episode type cache") | ||
loadingCache.invalidateAll() | ||
} | ||
|
||
fun getAll(): List<EpisodeType> = loadingCache.getUnchecked("") | ||
} |
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,23 @@ | ||
package fr.ziedelth.services | ||
|
||
import com.google.common.cache.CacheBuilder | ||
import com.google.common.cache.CacheLoader | ||
import fr.ziedelth.entities.LangType | ||
import fr.ziedelth.repositories.LangTypeRepository | ||
|
||
class LangTypeService(val repository: LangTypeRepository) { | ||
private val loadingCache = CacheBuilder.newBuilder() | ||
.build(object : CacheLoader<String, List<LangType>>() { | ||
override fun load(key: String): List<LangType> { | ||
println("Updating lang type cache") | ||
return repository.getAll() | ||
} | ||
}) | ||
|
||
fun invalidateAll() { | ||
println("Invalidate all lang type cache") | ||
loadingCache.invalidateAll() | ||
} | ||
|
||
fun getAll(): List<LangType> = loadingCache.getUnchecked("") | ||
} |
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