Last active
January 30, 2020 19:12
-
-
Save crypticminds/577fb1c747e309b0275b05a1351b01fa to your computer and use it in GitHub Desktop.
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
import com.arcane.coldstorageannotation.CacheKey | |
import com.arcane.coldstorageannotation.Freeze | |
import java.net.URL | |
/** | |
* Putting all the rest calls into this class and applying the annotation. | |
* It is optional to use the generatedClassName paramter. If no value is passed to it , the generated class | |
* will have the prefix Generated along with the original class name. Eg -> GeneratedMakeRemoteCallWithFreeze | |
**/ | |
@Freeze(generatedClassName = "MyBeautifulCacheLayer") | |
class MakeRemoteCallWithFreeze { | |
fun makeRemoteCallToServiceA(value: String): String { | |
val url = "https://httpbin.org/get?param1=$value" | |
val textResponse = URL(url).readText() | |
return textResponse | |
} | |
/** | |
* Here I am marking the parameters that will together form the cache key | |
* with @CacheKey | |
*/ | |
fun makeRemoteCallToServiceB( | |
@CacheKey parameter1: String, | |
@CacheKey parameter2: String, | |
parameter3: String | |
): String { | |
val url = "https://httpbin.org/get?param1=$parameter1¶m2=$parameter2¶m3=$parameter3" | |
val textResponse = URL(url).readText() | |
return textResponse | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment