This file contains hidden or 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
name: Deployment | |
on: | |
release: | |
types: [published] | |
jobs: | |
build: | |
runs-on: ubuntu-latest |
This file contains hidden or 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
public type AbstractCache abstract object { | |
public function put(string key, any value, int maxAgeInSeconds = -1) returns Error?; | |
public function get(string key) returns any|Error; | |
public function invalidate(string key) returns Error?; | |
public function invalidateAll() returns Error?; | |
public function hasKey(string key) returns boolean; | |
public function keys() returns string[]; | |
public function size() returns int; | |
public function capacity() returns int; | |
}; |
This file contains hidden or 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
public type AbstractEvictionPolicy abstract object { | |
public function get(LinkedList list, Node node); | |
public function put(LinkedList list, Node node); | |
public function remove(LinkedList list, Node node); | |
public function replace(LinkedList list, Node newNode, Node oldNode); | |
public function clear(LinkedList list); | |
public function evict(LinkedList list) returns Node?; | |
}; |
This file contains hidden or 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
public type Node record {| | |
any value; | |
Node? prev = (); | |
Node? next = (); | |
|}; | |
public type LinkedList record { | |
Node? head; | |
Node? tail; | |
}; |
This file contains hidden or 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
public type CacheConfig record {| | |
int capacity = 100; | |
AbstractEvictionPolicy evictionPolicy = new LruEvictionPolicy(); | |
float evictionFactor = 0.25; | |
int defaultMaxAgeInSeconds = -1; | |
int cleanupIntervalInSeconds?; | |
|}; |
This file contains hidden or 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
_ = check cache.put("key1", "value1"); | |
string value = <string> check cache.get("key1"); | |
_ = check cache.invalidate("key1"); | |
_ = check cache.invalidateAll(); | |
boolean hasKey = cache.hasKey("key1"); | |
string[] keys = cache.keys(); | |
int size = cache.size(); | |
int capacity = cache.capacity(); |
This file contains hidden or 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 | |
} |
This file contains hidden or 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
public type CustomCache object { | |
*AbstractCache; | |
private AbstractEvictionPolicy evictionPolicy; | |
private LinkedList list; | |
public function __init(AbstractEvictionPolicy evictionPolicy) { | |
self.evictionPolicy = evictionPolicy; | |
self.list = { |
This file contains hidden or 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
public type CustomEvictionPolicy object { | |
*cache:AbstractEvictionPolicy; | |
public function get(LinkedList list, Node node) { | |
// custom implementation related to updating the | |
// `LinkedList` based on the get operation. | |
} | |
} |
This file contains hidden or 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 ballerina/http; | |
import ballerina/graphql; | |
listener http:Listener apiGateway = new(9090, | |
secureSocket = { | |
key: { | |
certFile: "/path/to/public.crt", | |
keyFile: "/path/to/private.key" | |
} | |
} |