Skip to content

Instantly share code, notes, and snippets.

@crypticminds
Last active January 30, 2020 19:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save crypticminds/577fb1c747e309b0275b05a1351b01fa to your computer and use it in GitHub Desktop.
Save crypticminds/577fb1c747e309b0275b05a1351b01fa to your computer and use it in GitHub Desktop.
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&param2=$parameter2&param3=$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