Created
June 6, 2020 15:05
-
-
Save ldclakmal/801a625b52b72d7ad63e058e3311feaa to your computer and use it in GitHub Desktop.
Cache Usage with Error Handling
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
cache:Error? result = cache.put("key1", "value1"); | |
if (result is cache:Error) { | |
// implement what to do, if any error happen when inserting | |
// item to the cache | |
} | |
any|cache:Error result = cache.get("key1"); | |
if (result is cache:Error) { | |
// implement what to do, if any error happen when retrieving | |
// item from the cache | |
} | |
string value = <string>result; | |
cache:Error? result = check cache.invalidate("key1"); | |
if (result is cache:Error) { | |
// implement what to do, if any error happen when discarding | |
// item from the cache | |
} | |
cache:Error? result = check cache.invalidateAll(); | |
if (result is cache:Error) { | |
// implement what to do, if any error happen when discarding | |
// item from the cache | |
} | |
boolean hasKey = cache.hasKey("key1"); | |
string[] keys = cache.keys(); | |
int size = cache.size(); | |
int capacity = cache.capacity(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment