-
Notifications
You must be signed in to change notification settings - Fork 2
Caching
MemorisingFilters
(MatchFilters
and SummonerFilters
are both MemorisingFilters
), the SummonerHistory
and MemorisingEstimators
all utilise caches, specifically Guava Caches.
Below explains the caching implemented in each of the above classes:
-
MemorisingFilters
: we cache the boolean result from applying the filter on each input object. -
SummonerHistory
: we use a cache to store the visitedSummoners
, with their associatedMatchHistory
which was calculated in thecrawl
method of theCrawler
. -
MemorisingEstimators
: we cache the result from applying the estimator on each input object.
The caching is automatically implemented into each of the classes. However, each class offers additional support to configure its inner cache. One may construct each of the above classes with an additional parameter: which is a CacheBuilder
. The inner cache for each of the classes is created based upon the input CacheBuilder
, and when it's not specified, a default one is used.
One may construct their own CacheBuilder
by referring to Guava's CacheBuilder.
For example, constructing a CacheBuilder
which causes all entries to expire 3 hours after being written, with a maximum size of 1000 entries:
CacheBuilder.newBuilder()
.expireAfterWrite(3, TimeUnit.HOURS)
.maximumSize(1000);
As said above, there are default implementations of caches for the three main classes which use them. Below lists the CacheBuilder
properties for the default implementations in each of the three classes:
Class | expireAfterWrite | maximumSize |
---|---|---|
MemorisingFilter | 3 hours | 100,000 |
SummonerHistory | 1 day | 100,000 |
MemorisingEstimator | 3 hours | 100,000 |