Query Memoization
Utilities
Efficiently cache the results of any query in memory for an indicated period of time.
Installation
1api('com.psddev.component-lib:query-memoization-util')
Installing this plugin automatically adds the MemoizingDatabase to the database
stack. This can be disabled by setting dari/isQueryMemoizationEnabled to false
or per request with the query parameter ?_cache=false
Note that queries are not cached by default; each query must be opted in explicitly.
Usage
12class Test {3void main() {45int memoizationSeconds = 60;6Query query = Query.from(Article.class).where("x = y");78// Enable memoization on this query9MemoizingDatabase.setMemoizationSeconds(query, memoizationSeconds);1011// The results of this query are efficiently cached in memory for 6012// seconds across all requests.13PaginatedResult<Article> results = query.select(0, 10);14}15}