本文整理汇总了Java中javax.cache.integration.CacheWriter类的典型用法代码示例。如果您正苦于以下问题:Java CacheWriter类的具体用法?Java CacheWriter怎么用?Java CacheWriter使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
CacheWriter类属于javax.cache.integration包,在下文中一共展示了CacheWriter类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: JCache
import javax.cache.integration.CacheWriter; //导入依赖的package包/类
public JCache(JCacheManager cacheManager, Redisson redisson, String name, JCacheConfiguration<K, V> config, boolean hasOwnRedisson) {
super(redisson.getConfig().getCodec(), redisson.getCommandExecutor(), name);
this.hasOwnRedisson = hasOwnRedisson;
this.redisson = redisson;
Factory<CacheLoader<K, V>> cacheLoaderFactory = config.getCacheLoaderFactory();
if (cacheLoaderFactory != null) {
cacheLoader = cacheLoaderFactory.create();
}
Factory<CacheWriter<? super K, ? super V>> cacheWriterFactory = config.getCacheWriterFactory();
if (config.getCacheWriterFactory() != null) {
cacheWriter = (CacheWriter<K, V>) cacheWriterFactory.create();
}
this.cacheManager = cacheManager;
this.config = config;
redisson.getEvictionScheduler().scheduleJCache(getName(), getTimeoutSetName(), getExpiredChannelName());
for (CacheEntryListenerConfiguration<K, V> listenerConfig : config.getCacheEntryListenerConfigurations()) {
registerCacheEntryListener(listenerConfig, false);
}
}
示例2: WriteThruProviderMgr
import javax.cache.integration.CacheWriter; //导入依赖的package包/类
public WriteThruProviderMgr(String cacheName, CacheWriter writer, CacheRuntimeContext context, int timeout, long operationDelay, String providerName) throws ConfigurationException {
_context = context;
_cacheName = cacheName;
_operationDelay = operationDelay;
_myProvider = providerName;
_dsWriter = new JCacheWriteThruProvider((CacheWriter<Object,Object>)writer);
}
示例3: ActionRunner
import javax.cache.integration.CacheWriter; //导入依赖的package包/类
ActionRunner(ActionContext<K,V> actionContext)
{
// actionContext. It is currently taken directly from the Cache
CacheWriter<K, V> writer = actionContext.cacheWriter();
if (writer instanceof NopCacheWriter)
{
this.cacheWriter = null;
}
else
{
this.cacheWriter = actionContext.cacheWriter();
}
this.listeners = actionContext.listeners();
this.stats = actionContext.statisticsCalculator();
}
示例4: CacheWriterWrapper
import javax.cache.integration.CacheWriter; //导入依赖的package包/类
public CacheWriterWrapper(CacheWriter<? super K, ? super V> cw, boolean isAsync)
{
@SuppressWarnings("unchecked")
CacheWriter<K, V> cw2 = (CacheWriter<K, V>) cw;
this.cacheWriter = cw2;
// this.isAsync = isAsync;
}
示例5: GridCacheLoaderWriterStore
import javax.cache.integration.CacheWriter; //导入依赖的package包/类
/**
* @param ldr Loader.
* @param writer Writer.
*/
GridCacheLoaderWriterStore(@Nullable CacheLoader<K, V> ldr, @Nullable CacheWriter<K, V> writer) {
assert ldr != null || writer != null;
this.ldr = ldr;
this.writer = writer;
}
示例6: GridCacheLoaderWriterStoreFactory
import javax.cache.integration.CacheWriter; //导入依赖的package包/类
/**
* @param ldrFactory Loader factory.
* @param writerFactory Writer factory.
*/
GridCacheLoaderWriterStoreFactory(@Nullable Factory<CacheLoader<K, V>> ldrFactory,
@Nullable Factory<CacheWriter<K, V>> writerFactory) {
this.ldrFactory = ldrFactory;
this.writerFactory = writerFactory;
assert ldrFactory != null || writerFactory != null;
}
示例7: create
import javax.cache.integration.CacheWriter; //导入依赖的package包/类
/** {@inheritDoc} */
@Override public CacheStore<K, V> create() {
CacheLoader<K, V> ldr = ldrFactory == null ? null : ldrFactory.create();
CacheWriter<K, V> writer = writerFactory == null ? null : writerFactory.create();
return new GridCacheLoaderWriterStore<>(ldr, writer);
}
示例8: setCacheWriterFactory
import javax.cache.integration.CacheWriter; //导入依赖的package包/类
/** {@inheritDoc} */
@Override public CacheConfiguration<K, V> setCacheWriterFactory(
Factory<? extends CacheWriter<? super K, ? super V>> factory) {
super.setCacheWriterFactory(factory);
return this;
}
示例9: Eh107CacheLoaderWriter
import javax.cache.integration.CacheWriter; //导入依赖的package包/类
Eh107CacheLoaderWriter(CacheLoader<K, V> cacheLoader, boolean readThrough, CacheWriter<K, V> cacheWriter, boolean writeThrough) {
this.cacheLoader = cacheLoader;
this.readThrough = cacheLoader != null && readThrough;
if (writeThrough) {
this.cacheWriter = cacheWriter;
} else {
this.cacheWriter = null;
}
}
示例10: initCacheLoaderWriter
import javax.cache.integration.CacheWriter; //导入依赖的package包/类
private <K, V> Jsr107CacheLoaderWriter<K, V> initCacheLoaderWriter(CompleteConfiguration<K, V> config, MultiCacheException mce) {
Factory<CacheLoader<K, V>> cacheLoaderFactory = config.getCacheLoaderFactory();
@SuppressWarnings("unchecked")
Factory<CacheWriter<K, V>> cacheWriterFactory = (Factory<CacheWriter<K, V>>) (Object) config.getCacheWriterFactory();
if (config.isReadThrough() && cacheLoaderFactory == null) {
throw new IllegalArgumentException("read-through enabled without a CacheLoader factory provided");
}
if (config.isWriteThrough() && cacheWriterFactory == null) {
throw new IllegalArgumentException("write-through enabled without a CacheWriter factory provided");
}
CacheLoader<K, V> cacheLoader = cacheLoaderFactory == null ? null : cacheLoaderFactory.create();
CacheWriter<K, V> cacheWriter;
try {
cacheWriter = cacheWriterFactory == null ? null : cacheWriterFactory.create();
} catch (Throwable t) {
if (t != mce) {
mce.addThrowable(t);
}
CacheResources.close(cacheLoader, mce);
throw mce;
}
if (cacheLoader == null && cacheWriter == null) {
return null;
} else {
return new Eh107CacheLoaderWriter<>(cacheLoader, config.isReadThrough(), cacheWriter, config.isWriteThrough());
}
}
示例11: jsr107WriterGetsRegistered
import javax.cache.integration.CacheWriter; //导入依赖的package包/类
@Test
public void jsr107WriterGetsRegistered() {
MutableConfiguration<Object, Object> configuration = new MutableConfiguration<>();
CacheWriter<Object, Object> mock = mock(CacheWriter.class);
RecordingFactory<CacheWriter<Object, Object>> factory = factoryOf(mock);
configuration.setWriteThrough(true).setCacheWriterFactory(factory);
merger.mergeConfigurations("cache", configuration);
assertThat(factory.called, is(true));
verify(cacheLoaderWriterFactory).registerJsr107Loader(eq("cache"), ArgumentMatchers.<CacheLoaderWriter<Object, Object>>isNotNull());
}
示例12: getConfiguration
import javax.cache.integration.CacheWriter; //导入依赖的package包/类
private MutableConfiguration<Long, String> getConfiguration(final boolean readThrough, final CacheLoader<Long, String> cacheLoader,
final boolean writeThrough, final CacheWriter<Long, String> cacheWriter) {
MutableConfiguration<Long, String> config = new MutableConfiguration<>();
config.setTypes(Long.class, String.class);
config.setReadThrough(readThrough);
config.setCacheLoaderFactory(() -> cacheLoader);
config.setWriteThrough(writeThrough);
config.setCacheWriterFactory(() -> cacheWriter);
return config;
}
示例13: CacheWriterServer
import javax.cache.integration.CacheWriter; //导入依赖的package包/类
/**
* Constructs an CacheWriterServer.
*
* @param port the port on which to accept {@link CacheWriterClient} requests
* @param cacheWriter (optional) the {@link CacheWriter} that will be used to handle
* client requests
*/
public CacheWriterServer(int port, CacheWriter<K, V> cacheWriter) {
super(port);
// establish the client-server operation handlers
addOperationHandler(new WriteOperationHandler());
addOperationHandler(new WriteAllOperationHandler());
addOperationHandler(new DeleteOperationHandler());
addOperationHandler(new DeleteAllOperationHandler());
this.cacheWriter = cacheWriter;
}
示例14: getCacheWriterFactory
import javax.cache.integration.CacheWriter; //导入依赖的package包/类
@Override
public Factory<CacheWriter<? super K, ? super V>> getCacheWriterFactory() {
return delegate.getCacheWriterFactory();
}
示例15: getCacheWriterFactory
import javax.cache.integration.CacheWriter; //导入依赖的package包/类
/**
* The {@link CacheWriter} factory
*/
public Factory<CacheWriter> getCacheWriterFactory() {
return cacheWriterFactory;
}