3030import com .optimizely .ab .config .Attribute ;
3131import com .optimizely .ab .config .Experiment ;
3232import com .optimizely .ab .config .ProjectConfig ;
33- import com .optimizely .ab .internal .CacheWithRemove ;
33+ import com .optimizely .ab .internal .Cache ;
3434import com .optimizely .ab .internal .DefaultLRUCache ;
3535import com .optimizely .ab .optimizelydecision .OptimizelyDecideOption ;
3636
3737public class DefaultCmabService implements CmabService {
38- public static final int DEFAULT_CMAB_CACHE_SIZE = 1000 ;
39- public static final int DEFAULT_CMAB_CACHE_TIMEOUT_SECS = 300 ; // 5 minutes
38+ public static final int DEFAULT_CMAB_CACHE_SIZE = 10000 ;
39+ public static final int DEFAULT_CMAB_CACHE_TIMEOUT_SECS = 30 * 60 ; // 30 minutes
4040
41- private final CacheWithRemove <CmabCacheValue > cmabCache ;
41+ private final Cache <CmabCacheValue > cmabCache ;
4242 private final CmabClient cmabClient ;
4343 private final Logger logger ;
4444
45- public DefaultCmabService (CmabClient cmabClient , CacheWithRemove <CmabCacheValue > cmabCache ) {
45+ public DefaultCmabService (CmabClient cmabClient , Cache <CmabCacheValue > cmabCache ) {
4646 this (cmabClient , cmabCache , null );
4747 }
4848
49- public DefaultCmabService (CmabClient cmabClient , CacheWithRemove <CmabCacheValue > cmabCache , Logger logger ) {
49+ public DefaultCmabService (CmabClient cmabClient , Cache <CmabCacheValue > cmabCache , Logger logger ) {
5050 this .cmabCache = cmabCache ;
5151 this .cmabClient = cmabClient ;
5252 this .logger = logger != null ? logger : LoggerFactory .getLogger (DefaultCmabService .class );
@@ -199,13 +199,13 @@ public static Builder builder() {
199199 public static class Builder {
200200 private int cmabCacheSize = DEFAULT_CMAB_CACHE_SIZE ;
201201 private int cmabCacheTimeoutInSecs = DEFAULT_CMAB_CACHE_TIMEOUT_SECS ;
202- private CacheWithRemove <CmabCacheValue > customCache ;
202+ private Cache <CmabCacheValue > customCache ;
203203 private CmabClient client ;
204204
205205 /**
206206 * Set the maximum size of the CMAB cache.
207207 *
208- * Default value is 1000 entries.
208+ * Default value is 10000 entries.
209209 *
210210 * @param cacheSize The maximum number of entries to store in the cache
211211 * @return Builder instance
@@ -218,7 +218,7 @@ public Builder withCmabCacheSize(int cacheSize) {
218218 /**
219219 * Set the timeout duration for cached CMAB decisions.
220220 *
221- * Default value is 300 seconds (5 minutes).
221+ * Default value is 30 * 60 seconds (30 minutes).
222222 *
223223 * @param timeoutInSecs The timeout in seconds before cached entries expire
224224 * @return Builder instance
@@ -249,7 +249,7 @@ public Builder withClient(CmabClient client) {
249249 * @param cache The custom cache instance implementing {@link Cache}
250250 * @return Builder instance
251251 */
252- public Builder withCustomCache (CacheWithRemove <CmabCacheValue > cache ) {
252+ public Builder withCustomCache (Cache <CmabCacheValue > cache ) {
253253 this .customCache = cache ;
254254 return this ;
255255 }
@@ -259,7 +259,7 @@ public DefaultCmabService build() {
259259 throw new IllegalStateException ("CmabClient is required" );
260260 }
261261
262- CacheWithRemove <CmabCacheValue > cache = customCache != null ? customCache :
262+ Cache <CmabCacheValue > cache = customCache != null ? customCache :
263263 new DefaultLRUCache <>(cmabCacheSize , cmabCacheTimeoutInSecs );
264264
265265 return new DefaultCmabService (client , cache );
0 commit comments