Lines Matching +full:cache +full:- +full:to
47 cacheContext->get(LocaleCacheKey<UCTItem>(fLoc.getLanguage()), item, status); in createObject()
55 result->addRef(); in createObject()
99 const UnifiedCache *cache = UnifiedCache::getInstance(status); in TestEvictionUnderStress() local
100 int64_t evictedCountBefore = cache->autoEvictedCount(); in TestEvictionUnderStress()
104 int64_t evictedCountAfter = cache->autoEvictedCount(); in TestEvictionUnderStress()
106 dataerrln("%s:%d Items should have been evicted from cache", in TestEvictionUnderStress()
115 // We have to call this first or else calling the UnifiedCache in TestEvictionPolicy()
116 // ctor will fail. This is by design to deter clients from using the in TestEvictionPolicy()
117 // cache API incorrectly by creating their own cache instances. in TestEvictionPolicy()
120 // We create our own local UnifiedCache instance to ensure we have in TestEvictionPolicy()
122 // their own cache! in TestEvictionPolicy()
123 UnifiedCache cache(status); in TestEvictionPolicy() local
126 // Don't allow unused entries to exceed more than 100% of in use entries. in TestEvictionPolicy()
127 cache.setEvictionPolicy(0, 100, status); in TestEvictionPolicy()
136 // Add 5 in-use entries in TestEvictionPolicy()
138 cache.get( in TestEvictionPolicy()
140 &cache, in TestEvictionPolicy()
147 cache.get( in TestEvictionPolicy()
150 &cache, in TestEvictionPolicy()
154 unusedReference->removeRef(); in TestEvictionPolicy()
156 // unused count not to exceed in use count in TestEvictionPolicy()
157 assertEquals("T1", UPRV_LENGTHOF(usedReferences), cache.unusedCount()); in TestEvictionPolicy()
158 assertEquals("T2", 2*UPRV_LENGTHOF(usedReferences), cache.keyCount()); in TestEvictionPolicy()
162 usedReferences[i]->removeRef(); in TestEvictionPolicy()
165 // This should free up all cache items in TestEvictionPolicy()
166 assertEquals("T3", 0, cache.keyCount()); in TestEvictionPolicy()
176 // We have to call this first or else calling the UnifiedCache in TestBounded()
177 // ctor will fail. This is by design to deter clients from using the in TestBounded()
178 // cache API incorrectly by creating their own cache instances. in TestBounded()
181 // We create our own local UnifiedCache instance to ensure we have in TestBounded()
183 // their own cache! in TestBounded()
184 UnifiedCache cache(status); in TestBounded() local
188 cache.setEvictionPolicy(3, 0, status); in TestBounded()
190 // Our cache will hold up to 3 unused key-value pairs in TestBounded()
193 // 2. cache->get(X) always returns the same reference as long as caller in TestBounded()
194 // already holds references to that same object. in TestBounded()
196 // We first add 5 key-value pairs with two distinct values, "en" and "fr" in TestBounded()
204 cache.get(LocaleCacheKey<UCTItem>("en_US"), &cache, enUs, status); in TestBounded()
205 cache.get(LocaleCacheKey<UCTItem>("en"), &cache, en, status); in TestBounded()
206 assertEquals("T1", 1, cache.unusedCount()); in TestBounded()
207 cache.get(LocaleCacheKey<UCTItem>("en_GB"), &cache, enGb, status); in TestBounded()
208 cache.get(LocaleCacheKey<UCTItem>("fr_FR"), &cache, frFr, status); in TestBounded()
209 cache.get(LocaleCacheKey<UCTItem>("fr"), &cache, fr, status); in TestBounded()
213 assertEquals("T2", 3, cache.unusedCount()); in TestBounded()
214 assertEquals("T3", 5, cache.keyCount()); in TestBounded()
216 // Exercise cache more but don't hold the references except for in TestBounded()
217 // the last one. At the end of this, we will hold references to one in TestBounded()
218 // additional distinct value, so we will have references to 3 distinct in TestBounded()
221 cache.get(LocaleCacheKey<UCTItem>("zn_AA"), &cache, throwAway, status); in TestBounded()
222 cache.get(LocaleCacheKey<UCTItem>("sr_AA"), &cache, throwAway, status); in TestBounded()
223 cache.get(LocaleCacheKey<UCTItem>("de_AU"), &cache, throwAway, status); in TestBounded()
226 deAu->addRef(); in TestBounded()
229 // could have a total of 8 entries in the cache maxUnusedCount == 3 in TestBounded()
231 assertEquals("T4", 3, cache.unusedCount()); in TestBounded()
232 assertEquals("T5", 6, cache.keyCount()); in TestBounded()
234 // For all the references we have, cache must continue to return in TestBounded()
237 cache.get(LocaleCacheKey<UCTItem>("en"), &cache, throwAway, status); in TestBounded()
239 errln("T6: Expected en to resolve to the same object."); in TestBounded()
241 cache.get(LocaleCacheKey<UCTItem>("en_US"), &cache, throwAway, status); in TestBounded()
243 errln("T7: Expected enUs to resolve to the same object."); in TestBounded()
245 cache.get(LocaleCacheKey<UCTItem>("en_GB"), &cache, throwAway, status); in TestBounded()
247 errln("T8: Expected enGb to resolve to the same object."); in TestBounded()
249 cache.get(LocaleCacheKey<UCTItem>("fr_FR"), &cache, throwAway, status); in TestBounded()
251 errln("T9: Expected frFr to resolve to the same object."); in TestBounded()
253 cache.get(LocaleCacheKey<UCTItem>("fr_FR"), &cache, throwAway, status); in TestBounded()
254 cache.get(LocaleCacheKey<UCTItem>("fr"), &cache, throwAway, status); in TestBounded()
256 errln("T10: Expected fr to resolve to the same object."); in TestBounded()
258 cache.get(LocaleCacheKey<UCTItem>("de_AU"), &cache, throwAway, status); in TestBounded()
260 errln("T11: Expected deAu to resolve to the same object."); in TestBounded()
263 assertEquals("T12", 3, cache.unusedCount()); in TestBounded()
264 assertEquals("T13", 6, cache.keyCount()); in TestBounded()
266 // Now we hold a references to two more distinct values. Cache size in TestBounded()
267 // should grow to 8. in TestBounded()
270 cache.get(LocaleCacheKey<UCTItem>("es"), &cache, es, status); in TestBounded()
271 cache.get(LocaleCacheKey<UCTItem>("ru"), &cache, ru, status); in TestBounded()
272 assertEquals("T14", 3, cache.unusedCount()); in TestBounded()
273 assertEquals("T15", 8, cache.keyCount()); in TestBounded()
287 // Size of cache should magically drop to 3. in TestBounded()
288 assertEquals("T16", 3, cache.unusedCount()); in TestBounded()
289 assertEquals("T17", 3, cache.keyCount()); in TestBounded()
293 cache.setEvictionPolicy(3, 0, status); in TestBounded()
300 const UnifiedCache *cache = UnifiedCache::getInstance(status); in TestBasic() local
302 cache->flush(); in TestBasic()
303 int32_t baseCount = cache->keyCount(); in TestBasic()
310 cache->get(LocaleCacheKey<UCTItem>("en"), en, status); in TestBasic()
311 cache->get(LocaleCacheKey<UCTItem>("en_US"), enUs, status); in TestBasic()
312 cache->get(LocaleCacheKey<UCTItem>("en_GB"), enGb, status); in TestBasic()
313 cache->get(LocaleCacheKey<UCTItem>("fr_FR"), frFr, status); in TestBasic()
314 cache->get(LocaleCacheKey<UCTItem>("fr"), fr, status); in TestBasic()
315 cache->get(LocaleCacheKey<UCTItem>("en_GB"), enGb2, status); in TestBasic()
318 errln("Expected en_GB and en_US to resolve to same object."); in TestBasic()
321 errln("Expected fr and fr_FR to resolve to same object."); in TestBasic()
324 errln("Expected en_GB and fr to return different objects."); in TestBasic()
329 assertEquals("T2", baseCount + 5, cache->keyCount()); in TestBasic()
331 cache->flush(); in TestBasic()
333 // Only 2 unique values in the cache. flushing trims cache down in TestBasic()
334 // to this minimum size. in TestBasic()
335 assertEquals("T3", baseCount + 2, cache->keyCount()); in TestBasic()
338 cache->flush(); in TestBasic()
339 // With en_GB and en_US and en cleared there are no more hard references to in TestBasic()
340 // the "en" object, so it gets flushed and the keys that refer to it in TestBasic()
341 // get removed from the cache. Now we have just one unique value, fr, in in TestBasic()
342 // the cache in TestBasic()
343 assertEquals("T4", baseCount + 1, cache->keyCount()); in TestBasic()
345 cache->flush(); in TestBasic()
346 assertEquals("T5", baseCount + 1, cache->keyCount()); in TestBasic()
348 cache->flush(); in TestBasic()
349 assertEquals("T6", baseCount + 0, cache->keyCount()); in TestBasic()
355 const UnifiedCache *cache = UnifiedCache::getInstance(status); in TestError() local
357 cache->flush(); in TestError()
358 int32_t baseCount = cache->keyCount(); in TestError()
364 cache->get(LocaleCacheKey<UCTItem>("zh"), zh, status); in TestError()
369 cache->get(LocaleCacheKey<UCTItem>("zh_TW"), zhTw, status); in TestError()
374 cache->get(LocaleCacheKey<UCTItem>("zh_HK"), zhHk, status); in TestError()
378 // 3 keys in cache zh, zhTW, zhHk all pointing to error placeholders in TestError()
379 assertEquals("", baseCount + 3, cache->keyCount()); in TestError()
380 cache->flush(); in TestError()
382 assertEquals("", baseCount + 0, cache->keyCount()); in TestError()