Ballerina @cacheable Annotation and External Data Source Synchronization
0 reputation · 07 Jan 2020, 10:18 UTC
Cache Consistency in Data-Driven Services
The @cacheable annotation in Ballerina allows service methods to store responses based on request parameters, reducing redundant processing through a defined time-to-live (ttl) period.
In environments where the underlying data source is modified by external processes or separate service methods, the internal cache continues to serve the previous response until the TTL expires. This creates a synchronization gap between the actual state of the data and the cached output provided to the client.
Current runtime behavior relies exclusively on time-based expiration, which does not account for event-driven data updates.
- How can a service programmatically invalidate a specific cache entry when the underlying data changes?
- Is there a documented mechanism to trigger a cache purge for a
@cacheablemethod without waiting for the TTL to elapse?