本文整理汇总了Java中io.advantageous.qbit.time.Duration类的典型用法代码示例。如果您正苦于以下问题:Java Duration类的具体用法?Java Duration怎么用?Java Duration使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Duration类属于io.advantageous.qbit.time包,在下文中一共展示了Duration类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: putBytesWithConfirmationAndTimeout
import io.advantageous.qbit.time.Duration; //导入依赖的package包/类
@Override
public void putBytesWithConfirmationAndTimeout(final Callback<Boolean> confirmation,
final String key,
final byte[] value,
final Duration expiry) {
final SetOptions setOptions = new SetOptions();
setOptions.setPX(expiry.toMillis());
/* This redis client does not support this.
* https://github.com/vert-x3/vertx-redis-client/issues/41
* https://github.com/vert-x3/vertx-redis-client/issues/40
**/
redisClient.setWithOptions(key, new String(value), setOptions, event -> {
if (event.failed()) {
confirmation.onError(event.cause());
} else {
confirmation.accept(true);
}
});
}
示例2: putBytesWithTimeout
import io.advantageous.qbit.time.Duration; //导入依赖的package包/类
@Override
public void putBytesWithTimeout(final String key, final byte[] value,
final Duration expiry) {
final SetOptions setOptions = new SetOptions();
setOptions.setPX(expiry.toMillis());
/* This redis client does not support this.
* https://github.com/vert-x3/vertx-redis-client/issues/41
* https://github.com/vert-x3/vertx-redis-client/issues/40
**/
redisClient.setWithOptions(key, new String(value), setOptions, event -> {
if (event.failed()) {
logger.error(String.format("Error calling put bytes %s", key),
event.cause());
}
});
}
示例3: testBytes
import io.advantageous.qbit.time.Duration; //导入依赖的package包/类
/**
* Bytes are not really supported by the redis client yet.
*
* @throws Exception
*/
@Test
public void testBytes() throws Exception {
keyValueStore.putBytes("key1", "value1".getBytes());
keyValueStore.putBytesWithConfirmation(aBoolean -> {
}, "key2", "value2".getBytes());
keyValueStore.putBytesWithConfirmationAndTimeout(aBoolean -> {
}, "key3", "value3".getBytes(), Duration.SECONDS.units(2));
keyValueStore.putBytesWithTimeout("key4", "value4".getBytes(), Duration.FIVE_SECONDS);
keyValueStore.getBytes(bytes -> {
}, "key1");
keyValueStore.delete("key1");
keyValueStore.delete("key2");
keyValueStore.delete("key3");
keyValueStore.delete("key4");
}
示例4: setup
import io.advantageous.qbit.time.Duration; //导入依赖的package包/类
@Before
public void setup() {
// Create a serviceQueue with a serviceBuilder.
final ServiceBuilder serviceBuilder = serviceBuilder();
//Start the serviceQueue.
serviceQueue = serviceBuilder
.setServiceObject(new TodoManagerImpl())
.buildAndStartAll();
//Create a client proxy to communicate with the service actor.
client = serviceQueue.createProxyWithAutoFlush(TodoManagerClient.class,
Duration.milliseconds(5));
}
示例5: putWithConfirmationAndTimeout
import io.advantageous.qbit.time.Duration; //导入依赖的package包/类
@Override
public void putWithConfirmationAndTimeout(final Callback<Boolean> confirmation,
final String key,
final T value,
final Duration expiry) {
cache.put(key, cacheEntryWithExpiry(key, value, expiry));
final CallbackBuilder callbackBuilder = reactor.callbackBuilder();
if (debug) {
callbackBuilder.wrapWithLogging(confirmation, logger,
String.format("put with confirmation %s and timeout %s", key, expiry));
} else {
callbackBuilder.wrapWithLogging(confirmation, logger, "put with confirmation and timeout");
}
writeBehindWriter.writeWithConfirmationAndTimeout(callbackBuilder.build(), key, value, expiry);
}
示例6: setupWithDebug
import io.advantageous.qbit.time.Duration; //导入依赖的package包/类
public void setupWithDebug() {
lowLevelKVStore = LowLevelLocalKeyValueStoreServiceBuilder.localKeyValueStoreBuilder()
.setTimer(timer)
.buildAsServiceAndStartAll()
.createProxy(LowLevelKeyValueStoreService.class);
kvStore = LocalKeyValueStoreServiceBuilder.localKeyValueStoreServiceBuilder(Todo.class)
.setTimer(timer).setDebug(true).setDebugInterval(Duration.ONE_HOUR)
.setWriteBehindAndReadFallbackAsLowLevel(lowLevelKVStore)
.buildAsServiceAndStartAll().createProxy(KeyValueStoreService.class);
timer = new TestTimer();
Sys.sleep(100);
}
示例7: putStringWithConfirmationAndTimeout
import io.advantageous.qbit.time.Duration; //导入依赖的package包/类
@Override
public void putStringWithConfirmationAndTimeout(final Callback<Boolean> confirmation,
final String key,
final String value,
final Duration expiry) {
final SetOptions setOptions = new SetOptions();
setOptions.setPX(expiry.toMillis());
redisClient.setWithOptions(key, value, setOptions, event -> {
if (event.failed()) {
confirmation.onError(event.cause());
} else {
confirmation.accept(true);
}
});
}
示例8: putStringWithTimeout
import io.advantageous.qbit.time.Duration; //导入依赖的package包/类
@Override
public void putStringWithTimeout(final String key,
final String value,
final Duration expiry) {
final SetOptions setOptions = new SetOptions();
setOptions.setPX(expiry.toMillis());
redisClient.setWithOptions(key, value, setOptions, event -> {
if (event.failed()) {
logger.error(String.format("Error calling put string %s", key),
event.cause());
}
});
}
示例9: putStringWithConfirmationAndTimeout
import io.advantageous.qbit.time.Duration; //导入依赖的package包/类
@Override
public void putStringWithConfirmationAndTimeout(Callback<Boolean> confirmation, String key, String value, Duration expiry) {
final CallbackBuilder callbackBuilder = getCallbackBuilderForPut(confirmation, key);
localKeyValueStore.putStringWithConfirmationAndTimeout(callbackBuilder.build(), key, value, expiry);
remoteKeyValueStore.putStringWithConfirmationAndTimeout(callbackBuilder.build(), key, value, expiry);
}
示例10: putBytesWithConfirmationAndTimeout
import io.advantageous.qbit.time.Duration; //导入依赖的package包/类
@Override
public void putBytesWithConfirmationAndTimeout(Callback<Boolean> confirmation, String key, byte[] value, Duration expiry) {
final CallbackBuilder callbackBuilder = getCallbackBuilderForPut(confirmation, key);
localKeyValueStore.putBytesWithConfirmationAndTimeout(callbackBuilder.build(), key, value, expiry);
remoteKeyValueStore.putBytesWithConfirmationAndTimeout(callbackBuilder.build(), key, value, expiry);
}
示例11: LowLevelLocalKeyValueStoreService
import io.advantageous.qbit.time.Duration; //导入依赖的package包/类
public LowLevelLocalKeyValueStoreService(final Timer timer,
final Reactor reactor,
final int localCacheSize,
final StatsCollector statsCollector,
final Optional<Duration> flushCacheDuration,
final boolean debug) {
this.localCacheSize = localCacheSize;
this.timer = timer;
this.reactor = reactor;
this.statsCollector = statsCollector;
reactor.addServiceToFlush(statsCollector);
if (flushCacheDuration.isPresent()) {
reactor.addRepeatingTask(flushCacheDuration.get(), this::localCacheInit);
}
if (debug || logger.isDebugEnabled()) {
reactor.addRepeatingTask(TEN_SECONDS, this::debug);
}
reactor.addRepeatingTask(FIVE_SECONDS,
() -> statsCollector.recordLevel(CACHE_SIZE, localCache.size())
);
localCacheInit();
}
示例12: putStringWithConfirmationAndTimeout
import io.advantageous.qbit.time.Duration; //导入依赖的package包/类
@Override
public void putStringWithConfirmationAndTimeout(final Callback<Boolean> confirmation,
final String key,
final String value,
final Duration expiry) {
localCache.put(key, new CacheStringEntry(key, Optional.of(expiry), time, value));
confirmation.resolve(true);
}
示例13: build
import io.advantageous.qbit.time.Duration; //导入依赖的package包/类
public LowLevelLocalKeyValueStoreService build() {
return new LowLevelLocalKeyValueStoreService(
getTimer(),
getReactor(),
getLocalCacheSize(),
getStatsCollector(),
(flushCacheDuration == null) ? Optional.<Duration>empty() :
Optional.of(getFlushCacheDuration()),
isDebug());
}
示例14: LocalKeyValueStoreService
import io.advantageous.qbit.time.Duration; //导入依赖的package包/类
public LocalKeyValueStoreService(
final Reactor reactor,
final Timer timer,
final FallbackReader<T> fallbackReader,
final WriteBehindWriter<T> writeBehindWriter,
final int cacheSize,
final Duration flushEvery,
final StatsCollector statsCollector,
final String statKey,
final Duration debugInterval,
final boolean debug) {
this.fallbackReader = fallbackReader;
this.writeBehindWriter = writeBehindWriter;
this.cacheSize = cacheSize;
this.reactor = reactor;
this.reactor.addRepeatingTask(flushEvery, this::initCache);
this.statsCollector = statsCollector;
this.timer = timer;
this.statKey = statKey;
if (debugInterval != Duration.NEVER) {
this.reactor.addRepeatingTask(flushEvery, this::debugCache);
}
this.debug = debug || logger.isDebugEnabled();
initCache();
}
示例15: putWithTimeout
import io.advantageous.qbit.time.Duration; //导入依赖的package包/类
@Override
public void putWithTimeout(final String key,
final T value,
final Duration expiry) {
cache.put(key, cacheEntryWithExpiry(key, value, expiry));
writeBehindWriter.writeWithTimeout(key, value, expiry);
}