### Ballerina AbstractCache Object API Definition Source: https://github.com/ballerina-platform/module-ballerina-cache/blob/master/ballerina/README.md This API documentation defines the `AbstractCache` object type in Ballerina, which serves as a common interface for caching functionalities. It specifies the methods that any custom cache implementation should provide, including operations for putting, getting, invalidating, and querying cache entries, as well as checking key existence, retrieving all keys, and getting the cache's size and capacity. ```APIDOC public type AbstractCache object { public function put(string key, any value, int maxAgeInSeconds) 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; }; ``` -------------------------------- ### Get All Keys from Ballerina Cache Source: https://github.com/ballerina-platform/module-ballerina-cache/blob/master/docs/spec/spec.md Retrieves a list of all unique keys currently present in the cache. Returns a `string[]`. ```ballerina string[] keys = cache.keys(); ``` -------------------------------- ### Ballerina Cache AbstractCache Object API Definition Source: https://github.com/ballerina-platform/module-ballerina-cache/blob/master/README.md This defines the `AbstractCache` object type in Ballerina, outlining the common API for caching functionalities. It specifies methods for adding (`put`), retrieving (`get`), invalidating (`invalidate`, `invalidateAll`), checking existence (`hasKey`), listing keys (`keys`), and querying size and capacity of the cache. Custom cache implementations should structurally conform to this object. ```APIDOC public type AbstractCache object { public function put(string key, any value, int maxAgeInSeconds) 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; }; ``` -------------------------------- ### Get Current Size of Ballerina Cache Source: https://github.com/ballerina-platform/module-ballerina-cache/blob/master/docs/spec/spec.md Returns the current number of entries stored in the cache. Returns an `int`. ```ballerina int result = cache.size(); ``` -------------------------------- ### Get Maximum Capacity of Ballerina Cache Source: https://github.com/ballerina-platform/module-ballerina-cache/blob/master/docs/spec/spec.md Returns the maximum number of entries the cache can hold. Returns an `int`. ```ballerina int result = cache.capacity(); ``` -------------------------------- ### Run Ballerina Cache Module Tests Source: https://github.com/ballerina-platform/module-ballerina-cache/blob/master/README.md Executes all unit and integration tests for the Ballerina Cache module. ```Shell ./gradlew clean test ``` -------------------------------- ### Build Ballerina Cache Module Source: https://github.com/ballerina-platform/module-ballerina-cache/blob/master/README.md Compiles and packages the Ballerina Cache module from its source code. ```Shell ./gradlew clean build ``` -------------------------------- ### Publish Ballerina Cache Artifact to Local Maven Repository Source: https://github.com/ballerina-platform/module-ballerina-cache/blob/master/README.md Builds the Ballerina Cache module and publishes its generated ZIP artifact to the local Maven repository (typically located at `~/.m2/repository`). ```Shell ./gradlew clean build publishToMavenLocal ``` -------------------------------- ### Debug Ballerina Cache Module with Ballerina Language Source: https://github.com/ballerina-platform/module-ballerina-cache/blob/master/README.md Builds the Ballerina Cache module and enables remote debugging on the specified port for Ballerina language-level debugging. Replace `` with the desired debug port. ```Shell ./gradlew clean build -PbalJavaDebug= ``` -------------------------------- ### Debug Ballerina Cache Module Implementation (Java) Source: https://github.com/ballerina-platform/module-ballerina-cache/blob/master/README.md Builds the Ballerina Cache module and enables remote debugging on the specified port for Java-level debugging. Replace `` with the desired debug port. ```Shell ./gradlew clean build -Pdebug= ``` -------------------------------- ### Build Ballerina Cache Module Without Tests Source: https://github.com/ballerina-platform/module-ballerina-cache/blob/master/README.md Builds the Ballerina Cache module, skipping the execution of all tests. ```Shell ./gradlew clean build -x test ``` -------------------------------- ### Publish Ballerina Cache Artifact to Local Ballerina Central Source: https://github.com/ballerina-platform/module-ballerina-cache/blob/master/README.md Builds the Ballerina Cache module and publishes its generated artifacts to the local Ballerina Central repository, making them available for local Ballerina projects. ```Shell ./gradlew clean build -PpublishToLocalCentral=true ``` -------------------------------- ### Publish Ballerina Cache Artifact to Remote Ballerina Central Source: https://github.com/ballerina-platform/module-ballerina-cache/blob/master/README.md Builds the Ballerina Cache module and publishes its generated artifacts to the official Ballerina Central repository, making them publicly available. ```Shell ./gradlew clean build -PpublishToCentral=true ``` -------------------------------- ### Initialize Ballerina Cache with Custom Configuration Source: https://github.com/ballerina-platform/module-ballerina-cache/blob/master/ballerina/README.md This snippet demonstrates how to create a new `cache:Cache` instance in Ballerina, specifying optional configuration parameters. These parameters control the cache's capacity, eviction factor, default maximum age for entries, and the interval for automatic cleanup of expired entries. ```ballerina cache:Cache cache = new (capacity = 10, evictionFactor = 0.2, defaultMaxAge = 0.5, cleanupInterval = 1); ``` -------------------------------- ### Initialize Ballerina Cache with Configuration Source: https://github.com/ballerina-platform/module-ballerina-cache/blob/master/README.md This snippet demonstrates how to initialize a `cache:Cache` object in Ballerina. It allows for optional configuration of the cache's behavior, including its maximum `capacity`, `evictionFactor` for the LRU algorithm, `defaultMaxAge` for entries, and `cleanupInterval` for automatic expiration removal. ```ballerina cache:Cache cache = new (capacity = 10, evictionFactor = 0.2, defaultMaxAge = 0.5, cleanupInterval = 1); ``` -------------------------------- ### Run Specific Ballerina Cache Test Groups Source: https://github.com/ballerina-platform/module-ballerina-cache/blob/master/README.md Executes a specified group of tests for the Ballerina Cache module. Replace `` with the actual group names to target specific test suites. ```Shell ./gradlew clean test -Pgroups= ``` -------------------------------- ### Fetch Value from Ballerina Cache Source: https://github.com/ballerina-platform/module-ballerina-cache/blob/master/docs/spec/spec.md Retrieves the cached value associated with the provided key. Returns `any` type. ```ballerina any value = check cache.get("key"); ``` -------------------------------- ### Add Key-Value Pair to Ballerina Cache Source: https://github.com/ballerina-platform/module-ballerina-cache/blob/master/docs/spec/spec.md Adds a key-value pair to the cache with an entry expiration time. If the cache previously contained a value associated with the provided key, the old value will be replaced. The value cannot be `()` (nil). ```ballerina check cache.put("key", "value"); ``` -------------------------------- ### Discard All Entries from Ballerina Cache Source: https://github.com/ballerina-platform/module-ballerina-cache/blob/master/docs/spec/spec.md Removes all cached values, effectively clearing the entire cache. ```ballerina check cache.invalidateAll(); ``` -------------------------------- ### Check Key Existence in Ballerina Cache Source: https://github.com/ballerina-platform/module-ballerina-cache/blob/master/docs/spec/spec.md Determines if a given key has an associated cached value in the cache. Returns a boolean. ```ballerina boolean result = cache.hasKey("key"); ``` -------------------------------- ### Discard Single Entry from Ballerina Cache Source: https://github.com/ballerina-platform/module-ballerina-cache/blob/master/docs/spec/spec.md Removes a specific cached entry from the cache by its unique key. ```ballerina check cache.invalidate("key"); ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.