Back to project page couchbase-lite-android.
The source code is released under:
Apache License
If you think the Android project couchbase-lite-android listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
package com.couchbase.lite; /*www. jav a2 s . c o m*/ import java.util.HashMap; import java.util.Map; public class CacheTest extends LiteTestCase { public void testCache() throws Exception { int retainCount = 1; Cache cache = new Cache<String, Document>(retainCount); Map<String,Object> props = new HashMap<String, Object>(); props.put("foo", "bar"); Document doc1 = createDocumentWithProperties(database, props); cache.put(doc1.getId(), doc1); Map<String,Object> props2 = new HashMap<String, Object>(); props2.put("foo2", "bar2"); Document doc2 = createDocumentWithProperties(database, props2); cache.put(doc2.getId(), doc2); assertNotNull(cache.get(doc1.getId())); assertNotNull(cache.get(doc2.getId())); cache.remove(doc1.getId()); assertNull(cache.get(doc1.getId())); cache.clear(); assertNull(cache.get(doc2.getId())); } }