本文整理匯總了Java中com.couchbase.client.protocol.views.Stale類的典型用法代碼示例。如果您正苦於以下問題:Java Stale類的具體用法?Java Stale怎麽用?Java Stale使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
Stale類屬於com.couchbase.client.protocol.views包,在下文中一共展示了Stale類的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: setup
import com.couchbase.client.protocol.views.Stale; //導入依賴的package包/類
@Override
public void setup(OperatorContext context)
{
super.setup(context);
try {
className = Class.forName(outputClass);
} catch (ClassNotFoundException ex) {
throw new RuntimeException(ex);
}
view = store.getInstance().getView(designDocumentName, viewName);
query = new Query();
query.setStale(Stale.FALSE);
query.setIncludeDocs(true);
query.setLimit(limit);
query.setDescending(descending);
}
示例2: findByName
import com.couchbase.client.protocol.views.Stale; //導入依賴的package包/類
public static F.Promise<F.Option<User>> findByName(String name) {
Query query = new Query()
.setLimit(1)
.setIncludeDocs(true)
.setStale(Stale.FALSE)
.setRangeStart(ComplexKey.of(name))
.setRangeEnd(ComplexKey.of(name + "\uefff"));
return bucket.find("users", "by_name", query, User.class)
.map(new F.Function<Collection<User>, F.Option<User>>() {
@Override
public F.Option<User> apply(Collection<User> users) throws Throwable {
if (users.isEmpty()) {
return F.Option.None();
}
return F.Option.Some(users.iterator().next());
}
});
}
示例3: findByEmail
import com.couchbase.client.protocol.views.Stale; //導入依賴的package包/類
public static F.Promise<F.Option<User>> findByEmail(String email) {
Query query = new Query()
.setLimit(1)
.setIncludeDocs(true)
.setStale(Stale.FALSE)
.setRangeStart(ComplexKey.of(email))
.setRangeEnd(ComplexKey.of(email + "\uefff"));
return bucket.find("users", "by_email", query, User.class)
.map(new F.Function<Collection<User>, F.Option<User>>() {
@Override
public F.Option<User> apply(Collection<User> users) throws Throwable {
if (users.isEmpty()) {
return F.Option.None();
}
return F.Option.Some(users.iterator().next());
}
});
}
示例4: findByView
import com.couchbase.client.protocol.views.Stale; //導入依賴的package包/類
private void findByView(Message<JsonObject> message) throws NoSuchMethodException, IllegalAccessException, InvocationTargetException {
String designDoc = getMandatoryString("designDoc", message);
String viewName = getMandatoryString("viewName", message);
JsonObject query = getMandatoryObject("query", message);
if (designDoc == null || viewName == null || query == null) {
sendError(message, "designDoc and viewName and query must be specified");
return;
}
final Query q = new Query();
for(Entry<String, Object> entry : query.toMap().entrySet()) {
String setterMethod = "set" + capitalize(entry.getKey());
Object value = entry.getValue();
if(entry.getKey().equals("stale")) {
invokeMethod(q, setterMethod, Stale.valueOf((String)value));
}
else {
invokeMethod(q, setterMethod, value);
}
}
final View view = client.getView(designDoc, viewName);
final ViewResponse response = client.query(view, q);
final JsonArray result = new JsonArray();
for (final ViewRow row : response) {
CASValue<Object> object = client.gets(row.getId());
result.add(new JsonObject((String)object.getValue()));
}
sendOK(message, new JsonObject().putArray("result", result));
}
示例5: findAll
import com.couchbase.client.protocol.views.Stale; //導入依賴的package包/類
public static F.Promise<Collection<User>> findAll() {
return bucket.find("users", "by_name",
new Query().setIncludeDocs(true).setStale(Stale.FALSE), User.class);
}