Lines Matching full:cache
98 const UnifiedCache *cache = UnifiedCache::getInstance(status); in TestEvictionUnderStress() local
99 int64_t evictedCountBefore = cache->autoEvictedCount(); in TestEvictionUnderStress()
103 int64_t evictedCountAfter = cache->autoEvictedCount(); in TestEvictionUnderStress()
105 dataerrln("%s:%d Items should have been evicted from cache", in TestEvictionUnderStress()
116 // cache API incorrectly by creating their own cache instances. in TestEvictionPolicy()
121 // their own cache! in TestEvictionPolicy()
122 UnifiedCache cache(status); in TestEvictionPolicy() local
126 cache.setEvictionPolicy(0, 100, status); in TestEvictionPolicy()
137 cache.get( in TestEvictionPolicy()
139 &cache, in TestEvictionPolicy()
146 cache.get( in TestEvictionPolicy()
149 &cache, in TestEvictionPolicy()
156 assertEquals("", UPRV_LENGTHOF(usedReferences), cache.unusedCount()); in TestEvictionPolicy()
157 assertEquals("", 2*UPRV_LENGTHOF(usedReferences), cache.keyCount()); in TestEvictionPolicy()
164 // This should free up all cache items in TestEvictionPolicy()
165 assertEquals("", 0, cache.keyCount()); in TestEvictionPolicy()
177 // cache API incorrectly by creating their own cache instances. in TestBounded()
182 // their own cache! in TestBounded()
183 UnifiedCache cache(status); in TestBounded() local
187 cache.setEvictionPolicy(3, 0, status); in TestBounded()
189 // Our cache will hold up to 3 unused key-value pairs in TestBounded()
192 // 2. cache->get(X) always returns the same reference as long as caller in TestBounded()
203 cache.get(LocaleCacheKey<UCTItem>("en_US"), &cache, enUs, status); in TestBounded()
204 cache.get(LocaleCacheKey<UCTItem>("en"), &cache, en, status); in TestBounded()
205 assertEquals("", 1, cache.unusedCount()); in TestBounded()
206 cache.get(LocaleCacheKey<UCTItem>("en_GB"), &cache, enGb, status); in TestBounded()
207 cache.get(LocaleCacheKey<UCTItem>("fr_FR"), &cache, frFr, status); in TestBounded()
208 cache.get(LocaleCacheKey<UCTItem>("fr"), &cache, fr, status); in TestBounded()
212 assertEquals("", 3, cache.unusedCount()); in TestBounded()
213 assertEquals("", 5, cache.keyCount()); in TestBounded()
215 // Exercise cache more but don't hold the references except for in TestBounded()
220 cache.get(LocaleCacheKey<UCTItem>("zn_AA"), &cache, throwAway, status); in TestBounded()
221 cache.get(LocaleCacheKey<UCTItem>("sr_AA"), &cache, throwAway, status); in TestBounded()
222 cache.get(LocaleCacheKey<UCTItem>("de_AU"), &cache, throwAway, status); in TestBounded()
228 // could have a total of 8 entries in the cache maxUnusedCount == 3 in TestBounded()
230 assertEquals("", 3, cache.unusedCount()); in TestBounded()
231 assertEquals("", 6, cache.keyCount()); in TestBounded()
233 // For all the references we have, cache must continue to return in TestBounded()
236 cache.get(LocaleCacheKey<UCTItem>("en"), &cache, throwAway, status); in TestBounded()
240 cache.get(LocaleCacheKey<UCTItem>("en_US"), &cache, throwAway, status); in TestBounded()
244 cache.get(LocaleCacheKey<UCTItem>("en_GB"), &cache, throwAway, status); in TestBounded()
248 cache.get(LocaleCacheKey<UCTItem>("fr_FR"), &cache, throwAway, status); in TestBounded()
252 cache.get(LocaleCacheKey<UCTItem>("fr_FR"), &cache, throwAway, status); in TestBounded()
253 cache.get(LocaleCacheKey<UCTItem>("fr"), &cache, throwAway, status); in TestBounded()
257 cache.get(LocaleCacheKey<UCTItem>("de_AU"), &cache, throwAway, status); in TestBounded()
262 assertEquals("", 3, cache.unusedCount()); in TestBounded()
263 assertEquals("", 6, cache.keyCount()); in TestBounded()
265 // Now we hold a references to two more distinct values. Cache size in TestBounded()
269 cache.get(LocaleCacheKey<UCTItem>("es"), &cache, es, status); in TestBounded()
270 cache.get(LocaleCacheKey<UCTItem>("ru"), &cache, ru, status); in TestBounded()
271 assertEquals("", 3, cache.unusedCount()); in TestBounded()
272 assertEquals("", 8, cache.keyCount()); in TestBounded()
286 // Size of cache should magically drop to 3. in TestBounded()
287 assertEquals("", 3, cache.unusedCount()); in TestBounded()
288 assertEquals("", 3, cache.keyCount()); in TestBounded()
292 cache.setEvictionPolicy(3, 0, status); in TestBounded()
299 const UnifiedCache *cache = UnifiedCache::getInstance(status); in TestBasic() local
301 cache->flush(); in TestBasic()
302 int32_t baseCount = cache->keyCount(); in TestBasic()
309 cache->get(LocaleCacheKey<UCTItem>("en"), en, status); in TestBasic()
310 cache->get(LocaleCacheKey<UCTItem>("en_US"), enUs, status); in TestBasic()
311 cache->get(LocaleCacheKey<UCTItem>("en_GB"), enGb, status); in TestBasic()
312 cache->get(LocaleCacheKey<UCTItem>("fr_FR"), frFr, status); in TestBasic()
313 cache->get(LocaleCacheKey<UCTItem>("fr"), fr, status); in TestBasic()
314 cache->get(LocaleCacheKey<UCTItem>("en_GB"), enGb2, status); in TestBasic()
328 assertEquals("", baseCount + 5, cache->keyCount()); in TestBasic()
330 cache->flush(); in TestBasic()
332 // Only 2 unique values in the cache. flushing trims cache down in TestBasic()
334 assertEquals("", baseCount + 2, cache->keyCount()); in TestBasic()
337 cache->flush(); in TestBasic()
340 // get removed from the cache. Now we have just one unique value, fr, in in TestBasic()
341 // the cache in TestBasic()
342 assertEquals("", baseCount + 1, cache->keyCount()); in TestBasic()
344 cache->flush(); in TestBasic()
345 assertEquals("", baseCount + 1, cache->keyCount()); in TestBasic()
347 cache->flush(); in TestBasic()
348 assertEquals("", baseCount + 0, cache->keyCount()); in TestBasic()
354 const UnifiedCache *cache = UnifiedCache::getInstance(status); in TestError() local
356 cache->flush(); in TestError()
357 int32_t baseCount = cache->keyCount(); in TestError()
363 cache->get(LocaleCacheKey<UCTItem>("zh"), zh, status); in TestError()
368 cache->get(LocaleCacheKey<UCTItem>("zh_TW"), zhTw, status); in TestError()
373 cache->get(LocaleCacheKey<UCTItem>("zh_HK"), zhHk, status); in TestError()
377 // 3 keys in cache zh, zhTW, zhHk all pointing to error placeholders in TestError()
378 assertEquals("", baseCount + 3, cache->keyCount()); in TestError()
379 cache->flush(); in TestError()
381 assertEquals("", baseCount + 0, cache->keyCount()); in TestError()