Last active
December 20, 2015 16:39
-
-
Save tgrall/6162974 to your computer and use it in GitHub Desktop.
Very simple query cache for Couchbase
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//... | |
Object o = cb.get("query-result-001"); | |
if (o == null) { | |
View view = cb.getView("brewery", "by_name"); | |
Query query = new Query(); | |
query.setLimit(100); | |
Map<String, String> result = new HashMap<String,String>(); | |
ViewResponse viewResponse = cb.query(view, query); | |
for (ViewRow row : viewResponse) { | |
result.put(row.getId(), row.getKey()); | |
} | |
System.out.println(viewResponse); | |
System.out.println( result ); | |
cb.set("query-result-001", 10, json.toJson(result)); | |
} | |
//... |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment