org.infinispan.api.sync.SyncQuery Maven / Gradle / Ivy
The newest version!
package org.infinispan.api.sync;
import java.util.Map;
import org.infinispan.api.common.process.CacheProcessor;
import org.infinispan.api.common.process.CacheProcessorOptions;
import org.infinispan.api.sync.events.cache.SyncCacheContinuousQueryListener;
/**
* Parameterized Query builder
*
* @param
* @param
* @param the result type for the query
*/
public interface SyncQuery {
/**
* Sets the named parameter to the specified value
*
* @param name
* @param value
* @return
*/
SyncQuery param(String name, Object value);
/**
* Skips the first specified number of results
*
* @param skip
* @return
*/
SyncQuery skip(long skip);
/**
* Limits the number of results
*
* @param limit
* @return
*/
SyncQuery limit(int limit);
/**
* Executes the query
*/
SyncQueryResult find();
/**
* Continuously listen on query
*
* @param listener
* @param
* @return A {@link AutoCloseable} that allows to remove the listener via {@link AutoCloseable#close()}.
*/
AutoCloseable findContinuously(SyncCacheContinuousQueryListener listener);
/**
* Executes the manipulation statement (UPDATE, REMOVE)
*
* @return the number of entries that were processed
*/
int execute();
/**
* Processes entries using an {@link SyncCacheEntryProcessor}. If the cache is embedded, the consumer will be executed
* locally on the owner of the entry. If the cache is remote, entries will be retrieved, manipulated locally and put
* back. The query MUST NOT use projections.
*
* @param processor the entry processor
*/
default Map process(SyncCacheEntryProcessor processor) {
return process(processor, CacheProcessorOptions.DEFAULT);
}
/**
* Processes entries using a {@link SyncCacheEntryProcessor}. If the cache is embedded, the consumer will be executed
* locally on the owner of the entry. If the cache is remote, entries will be retrieved, manipulated locally and put
* back. The query MUST NOT use projections.
*
* @param
* @param processor the entry processor
* @param options
*/
Map process(SyncCacheEntryProcessor processor, CacheProcessorOptions options);
/**
* Processes entries matched by the query using a named {@link CacheProcessor}. The query MUST NOT use projections.
* If the cache processor returns a non-null value for an entry, it will be returned as an entry of a {@link Map}.
*
* @param processor the entry processor
* @return
*/
default Map process(CacheProcessor processor) {
return process(processor, CacheProcessorOptions.DEFAULT);
}
/**
* Processes entries matched by the query using a named {@link CacheProcessor}. The query MUST NOT use projections.
* If the cache processor returns a non-null value for an entry, it will be returned as an entry of a {@link Map}.
*
* @param
* @param processor the named entry processor
* @param options
* @return
*/
Map process(CacheProcessor processor, CacheProcessorOptions options);
}