You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In the above example **url** and **data** will together form the key of the cache , such that if it determines that the same url and data is passed to the function (until the value expires in the cache) irrespective of the value of "**someRandomVariable**" it will
201
-
return the data from the cache. Using the **keys** parameter you can decide which variables should form the key of the cache for the annotated function.
177
+
In the above example **url** and **data** will together form the key of the cache , such that if it determines that the same url and data is passed to the function (until the value expires in the cache) irrespective of the value of "**variableThatIsNotAKey**" it will
178
+
return the data from the cache.
202
179
203
180
During compilation the annotations will generate a class "**GeneratedCacheLayer**
204
181
and instead of using your annotated functions directly you will use them via this class.
@@ -211,7 +188,7 @@ To invoke the above functions you will call :-
The generated method will have the same name and accept the same variables as the original method but with two extra parameters , one is the object of the class where the original annotated method is present in and the second is the callback (**OnOperationsuccessfulCallback**) which will be used to pass the cached data to the main thread from the background thread. (All cache operations take place on a separate thread). For more information about the usage check the example below or the [article](https://medium.com/@crypticmindscom_5258/caching-made-easy-in-android-with-kotlin-part-2-61bb476063b4)
191
+
The generated method will have the same name and accept the same variables as the original method but with two extra parameters , one is the object of the class where the original annotated method is present in and the second is the callback (**OnOperationsuccessfulCallback**) which will be used to pass the cached data to the main thread from the background thread. (All cache operations take place on a separate thread). Check the [wiki](https://github.com/crypticminds/ColdStorage/wiki/@Refrigerate-annotation) for more details.
215
192
216
193
> After applying the annotation you can try running your application on AVD so that the GeneratedCacheLayer file is created. Then use it just like
217
194
> a regular class in your project. Your IDE will be able to index it
@@ -276,7 +253,7 @@ The generated method will have the same name and accept the same variables as th
276
253
}
277
254
```
278
255
279
-
**The update method should return the value to be cahced in form of a string. If you are planning to store complex objects , serialize them into a string and return them from the method.**
256
+
**The update method should return the value to be cached in form of a string. If you are planning to store complex objects , serialize them into a string and return them from the method.**
280
257
281
258
Your cache is now ready. To use the cache create an instance of it and call the **get** method of the cache.
0 commit comments