Skip to content

Instantly share code, notes, and snippets.

@tgrall
Last active December 20, 2015 16:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tgrall/6162974 to your computer and use it in GitHub Desktop.
Save tgrall/6162974 to your computer and use it in GitHub Desktop.
Very simple query cache for Couchbase
//...
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