Skip to content

Instantly share code, notes, and snippets.

@ldclakmal
Created June 6, 2020 15:05
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 ldclakmal/507303557ab12282349ca885e87946b0 to your computer and use it in GitHub Desktop.
Save ldclakmal/507303557ab12282349ca885e87946b0 to your computer and use it in GitHub Desktop.
Custom Cache of Ballerina
public type CustomCache object {
*AbstractCache;
private AbstractEvictionPolicy evictionPolicy;
private LinkedList list;
public function __init(AbstractEvictionPolicy evictionPolicy) {
self.evictionPolicy = evictionPolicy;
self.list = {
head: (),
tail: ()
};
}
public function get(string key) returns any|Error {
// custom implementation related to retrieving the `Node`
// from the persistence storage.
self.evictionPolicy.get(self.list, node);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment