code stringlengths 23 201k | docstring stringlengths 17 96.2k | func_name stringlengths 0 235 | language stringclasses 1
value | repo stringlengths 8 72 | path stringlengths 11 317 | url stringlengths 57 377 | license stringclasses 7
values |
|---|---|---|---|---|---|---|---|
public GlobalCacheConfig getGlobalCacheConfig() {
return globalCacheConfig;
} | Keep this method for backward compatibility.
NOTICE: there is no getter for keyConvertorParser. | getGlobalCacheConfig | java | alibaba/jetcache | jetcache-anno/src/main/java/com/alicp/jetcache/anno/support/ConfigProvider.java | https://github.com/alibaba/jetcache/blob/master/jetcache-anno/src/main/java/com/alicp/jetcache/anno/support/ConfigProvider.java | Apache-2.0 |
public void setGlobalCacheConfig(GlobalCacheConfig globalCacheConfig) {
this.globalCacheConfig = globalCacheConfig;
} | Keep this method for backward compatibility.
NOTICE: there is no getter for keyConvertorParser. | setGlobalCacheConfig | java | alibaba/jetcache | jetcache-anno/src/main/java/com/alicp/jetcache/anno/support/ConfigProvider.java | https://github.com/alibaba/jetcache/blob/master/jetcache-anno/src/main/java/com/alicp/jetcache/anno/support/ConfigProvider.java | Apache-2.0 |
public void setMetricsCallback(Consumer<StatInfo> metricsCallback) {
this.metricsCallback = metricsCallback;
} | Keep this method for backward compatibility.
NOTICE: there is no getter for keyConvertorParser. | setMetricsCallback | java | alibaba/jetcache | jetcache-anno/src/main/java/com/alicp/jetcache/anno/support/ConfigProvider.java | https://github.com/alibaba/jetcache/blob/master/jetcache-anno/src/main/java/com/alicp/jetcache/anno/support/ConfigProvider.java | Apache-2.0 |
public String[] getHiddenPackages() {
return hiddenPackages;
} | for compatible reason. This property controls whether add area as remote cache key prefix.
version<=2.4.3: add cache area in prefix, no config.
version>2.4.3 and version <2.7: default value is true, keep same as 2.4.3 if not set.
version>=2.7.0.RC: default value is false.
remove in the future. | getHiddenPackages | java | alibaba/jetcache | jetcache-anno/src/main/java/com/alicp/jetcache/anno/support/GlobalCacheConfig.java | https://github.com/alibaba/jetcache/blob/master/jetcache-anno/src/main/java/com/alicp/jetcache/anno/support/GlobalCacheConfig.java | Apache-2.0 |
public void setHiddenPackages(String[] hiddenPackages) {
this.hiddenPackages = hiddenPackages;
} | for compatible reason. This property controls whether add area as remote cache key prefix.
version<=2.4.3: add cache area in prefix, no config.
version>2.4.3 and version <2.7: default value is true, keep same as 2.4.3 if not set.
version>=2.7.0.RC: default value is false.
remove in the future. | setHiddenPackages | java | alibaba/jetcache | jetcache-anno/src/main/java/com/alicp/jetcache/anno/support/GlobalCacheConfig.java | https://github.com/alibaba/jetcache/blob/master/jetcache-anno/src/main/java/com/alicp/jetcache/anno/support/GlobalCacheConfig.java | Apache-2.0 |
public Map<String, CacheBuilder> getLocalCacheBuilders() {
return localCacheBuilders;
} | for compatible reason. This property controls whether add area as remote cache key prefix.
version<=2.4.3: add cache area in prefix, no config.
version>2.4.3 and version <2.7: default value is true, keep same as 2.4.3 if not set.
version>=2.7.0.RC: default value is false.
remove in the future. | getLocalCacheBuilders | java | alibaba/jetcache | jetcache-anno/src/main/java/com/alicp/jetcache/anno/support/GlobalCacheConfig.java | https://github.com/alibaba/jetcache/blob/master/jetcache-anno/src/main/java/com/alicp/jetcache/anno/support/GlobalCacheConfig.java | Apache-2.0 |
public void setLocalCacheBuilders(Map<String, CacheBuilder> localCacheBuilders) {
this.localCacheBuilders = localCacheBuilders;
} | for compatible reason. This property controls whether add area as remote cache key prefix.
version<=2.4.3: add cache area in prefix, no config.
version>2.4.3 and version <2.7: default value is true, keep same as 2.4.3 if not set.
version>=2.7.0.RC: default value is false.
remove in the future. | setLocalCacheBuilders | java | alibaba/jetcache | jetcache-anno/src/main/java/com/alicp/jetcache/anno/support/GlobalCacheConfig.java | https://github.com/alibaba/jetcache/blob/master/jetcache-anno/src/main/java/com/alicp/jetcache/anno/support/GlobalCacheConfig.java | Apache-2.0 |
public Map<String, CacheBuilder> getRemoteCacheBuilders() {
return remoteCacheBuilders;
} | for compatible reason. This property controls whether add area as remote cache key prefix.
version<=2.4.3: add cache area in prefix, no config.
version>2.4.3 and version <2.7: default value is true, keep same as 2.4.3 if not set.
version>=2.7.0.RC: default value is false.
remove in the future. | getRemoteCacheBuilders | java | alibaba/jetcache | jetcache-anno/src/main/java/com/alicp/jetcache/anno/support/GlobalCacheConfig.java | https://github.com/alibaba/jetcache/blob/master/jetcache-anno/src/main/java/com/alicp/jetcache/anno/support/GlobalCacheConfig.java | Apache-2.0 |
public void setRemoteCacheBuilders(Map<String, CacheBuilder> remoteCacheBuilders) {
this.remoteCacheBuilders = remoteCacheBuilders;
} | for compatible reason. This property controls whether add area as remote cache key prefix.
version<=2.4.3: add cache area in prefix, no config.
version>2.4.3 and version <2.7: default value is true, keep same as 2.4.3 if not set.
version>=2.7.0.RC: default value is false.
remove in the future. | setRemoteCacheBuilders | java | alibaba/jetcache | jetcache-anno/src/main/java/com/alicp/jetcache/anno/support/GlobalCacheConfig.java | https://github.com/alibaba/jetcache/blob/master/jetcache-anno/src/main/java/com/alicp/jetcache/anno/support/GlobalCacheConfig.java | Apache-2.0 |
public int getStatIntervalMinutes() {
return statIntervalMinutes;
} | for compatible reason. This property controls whether add area as remote cache key prefix.
version<=2.4.3: add cache area in prefix, no config.
version>2.4.3 and version <2.7: default value is true, keep same as 2.4.3 if not set.
version>=2.7.0.RC: default value is false.
remove in the future. | getStatIntervalMinutes | java | alibaba/jetcache | jetcache-anno/src/main/java/com/alicp/jetcache/anno/support/GlobalCacheConfig.java | https://github.com/alibaba/jetcache/blob/master/jetcache-anno/src/main/java/com/alicp/jetcache/anno/support/GlobalCacheConfig.java | Apache-2.0 |
public void setStatIntervalMinutes(int statIntervalMinutes) {
this.statIntervalMinutes = statIntervalMinutes;
} | for compatible reason. This property controls whether add area as remote cache key prefix.
version<=2.4.3: add cache area in prefix, no config.
version>2.4.3 and version <2.7: default value is true, keep same as 2.4.3 if not set.
version>=2.7.0.RC: default value is false.
remove in the future. | setStatIntervalMinutes | java | alibaba/jetcache | jetcache-anno/src/main/java/com/alicp/jetcache/anno/support/GlobalCacheConfig.java | https://github.com/alibaba/jetcache/blob/master/jetcache-anno/src/main/java/com/alicp/jetcache/anno/support/GlobalCacheConfig.java | Apache-2.0 |
@Deprecated
public boolean isAreaInCacheName() {
return areaInCacheName;
} | for compatible reason. This property controls whether add area as remote cache key prefix.
version<=2.4.3: add cache area in prefix, no config.
version>2.4.3 and version <2.7: default value is true, keep same as 2.4.3 if not set.
version>=2.7.0.RC: default value is false.
remove in the future. | isAreaInCacheName | java | alibaba/jetcache | jetcache-anno/src/main/java/com/alicp/jetcache/anno/support/GlobalCacheConfig.java | https://github.com/alibaba/jetcache/blob/master/jetcache-anno/src/main/java/com/alicp/jetcache/anno/support/GlobalCacheConfig.java | Apache-2.0 |
@Deprecated
public void setAreaInCacheName(boolean areaInCacheName) {
this.areaInCacheName = areaInCacheName;
} | for compatible reason. This property controls whether add area as remote cache key prefix.
version<=2.4.3: add cache area in prefix, no config.
version>2.4.3 and version <2.7: default value is true, keep same as 2.4.3 if not set.
version>=2.7.0.RC: default value is false.
remove in the future. | setAreaInCacheName | java | alibaba/jetcache | jetcache-anno/src/main/java/com/alicp/jetcache/anno/support/GlobalCacheConfig.java | https://github.com/alibaba/jetcache/blob/master/jetcache-anno/src/main/java/com/alicp/jetcache/anno/support/GlobalCacheConfig.java | Apache-2.0 |
public boolean isPenetrationProtect() {
return penetrationProtect;
} | for compatible reason. This property controls whether add area as remote cache key prefix.
version<=2.4.3: add cache area in prefix, no config.
version>2.4.3 and version <2.7: default value is true, keep same as 2.4.3 if not set.
version>=2.7.0.RC: default value is false.
remove in the future. | isPenetrationProtect | java | alibaba/jetcache | jetcache-anno/src/main/java/com/alicp/jetcache/anno/support/GlobalCacheConfig.java | https://github.com/alibaba/jetcache/blob/master/jetcache-anno/src/main/java/com/alicp/jetcache/anno/support/GlobalCacheConfig.java | Apache-2.0 |
public void setPenetrationProtect(boolean penetrationProtect) {
this.penetrationProtect = penetrationProtect;
} | for compatible reason. This property controls whether add area as remote cache key prefix.
version<=2.4.3: add cache area in prefix, no config.
version>2.4.3 and version <2.7: default value is true, keep same as 2.4.3 if not set.
version>=2.7.0.RC: default value is false.
remove in the future. | setPenetrationProtect | java | alibaba/jetcache | jetcache-anno/src/main/java/com/alicp/jetcache/anno/support/GlobalCacheConfig.java | https://github.com/alibaba/jetcache/blob/master/jetcache-anno/src/main/java/com/alicp/jetcache/anno/support/GlobalCacheConfig.java | Apache-2.0 |
public boolean isEnableMethodCache() {
return enableMethodCache;
} | for compatible reason. This property controls whether add area as remote cache key prefix.
version<=2.4.3: add cache area in prefix, no config.
version>2.4.3 and version <2.7: default value is true, keep same as 2.4.3 if not set.
version>=2.7.0.RC: default value is false.
remove in the future. | isEnableMethodCache | java | alibaba/jetcache | jetcache-anno/src/main/java/com/alicp/jetcache/anno/support/GlobalCacheConfig.java | https://github.com/alibaba/jetcache/blob/master/jetcache-anno/src/main/java/com/alicp/jetcache/anno/support/GlobalCacheConfig.java | Apache-2.0 |
public void setEnableMethodCache(boolean enableMethodCache) {
this.enableMethodCache = enableMethodCache;
} | for compatible reason. This property controls whether add area as remote cache key prefix.
version<=2.4.3: add cache area in prefix, no config.
version>2.4.3 and version <2.7: default value is true, keep same as 2.4.3 if not set.
version>=2.7.0.RC: default value is false.
remove in the future. | setEnableMethodCache | java | alibaba/jetcache | jetcache-anno/src/main/java/com/alicp/jetcache/anno/support/GlobalCacheConfig.java | https://github.com/alibaba/jetcache/blob/master/jetcache-anno/src/main/java/com/alicp/jetcache/anno/support/GlobalCacheConfig.java | Apache-2.0 |
protected SpringConfigProvider createConfigProvider() {
return new SpringConfigProvider();
} | used in non-spring-boot projects.
@author huangli | createConfigProvider | java | alibaba/jetcache | jetcache-anno/src/main/java/com/alicp/jetcache/anno/support/JetCacheBaseBeans.java | https://github.com/alibaba/jetcache/blob/master/jetcache-anno/src/main/java/com/alicp/jetcache/anno/support/JetCacheBaseBeans.java | Apache-2.0 |
@Bean(destroyMethod = "shutdown")
public SpringConfigProvider springConfigProvider(
@Autowired ApplicationContext applicationContext,
@Autowired GlobalCacheConfig globalCacheConfig,
@Autowired(required = false) EncoderParser encoderParser,
@Autowired(required = false)... | used in non-spring-boot projects.
@author huangli | springConfigProvider | java | alibaba/jetcache | jetcache-anno/src/main/java/com/alicp/jetcache/anno/support/JetCacheBaseBeans.java | https://github.com/alibaba/jetcache/blob/master/jetcache-anno/src/main/java/com/alicp/jetcache/anno/support/JetCacheBaseBeans.java | Apache-2.0 |
@Bean(name = "jcCacheManager",destroyMethod = "close")
public SimpleCacheManager cacheManager(@Autowired ConfigProvider configProvider) {
SimpleCacheManager cacheManager = new SimpleCacheManager();
cacheManager.setCacheBuilderTemplate(configProvider.getCacheBuilderTemplate());
return cacheMa... | used in non-spring-boot projects.
@author huangli | cacheManager | java | alibaba/jetcache | jetcache-anno/src/main/java/com/alicp/jetcache/anno/support/JetCacheBaseBeans.java | https://github.com/alibaba/jetcache/blob/master/jetcache-anno/src/main/java/com/alicp/jetcache/anno/support/JetCacheBaseBeans.java | Apache-2.0 |
default V get(K key) throws CacheInvokeException {
CacheGetResult<V> result = GET(key);
if (result.isSuccess()) {
return result.getValue();
} else {
return null;
}
} | Gets an entry from the cache.
<p>If the cache's builder has specified a {@link CacheLoader} and there is no association in the cache
, it will attempt to load the entry.</p>
<p>If error occurs during cache access, the method return null instead of throwing an exception.</p>
@param key the key whose associated value is ... | get | java | alibaba/jetcache | jetcache-core/src/main/java/com/alicp/jetcache/Cache.java | https://github.com/alibaba/jetcache/blob/master/jetcache-core/src/main/java/com/alicp/jetcache/Cache.java | Apache-2.0 |
default Map<K, V> getAll(Set<? extends K> keys) throws CacheInvokeException {
MultiGetResult<K, V> cacheGetResults = GET_ALL(keys);
return cacheGetResults.unwrapValues();
} | Gets a collection of entries from the Cache, returning them as Map of the values associated with
the set of keys requested.
<p>If the cache's builder has specified a {@link CacheLoader} and there is no association in the cache
, it will attempt to load the entry.</p>
<p>If error occurs during cache access, the method w... | getAll | java | alibaba/jetcache | jetcache-core/src/main/java/com/alicp/jetcache/Cache.java | https://github.com/alibaba/jetcache/blob/master/jetcache-core/src/main/java/com/alicp/jetcache/Cache.java | Apache-2.0 |
default void put(K key, V value) {
PUT(key, value);
} | Associates the specified value with the specified key in the cache.
<p>If error occurs during cache access, the method will not throw an exception.</p>
<p>if the implementation supports asynchronous operation, the cache operation of this method is asynchronous.</p>
@param key key with which the specified value is to be... | put | java | alibaba/jetcache | jetcache-core/src/main/java/com/alicp/jetcache/Cache.java | https://github.com/alibaba/jetcache/blob/master/jetcache-core/src/main/java/com/alicp/jetcache/Cache.java | Apache-2.0 |
default boolean putIfAbsent(K key, V value) {
CacheResult result = PUT_IF_ABSENT(key, value, config().getExpireAfterWriteInMillis(), TimeUnit.MILLISECONDS);
return result.getResultCode() == CacheResultCode.SUCCESS;
} | Atomically associates the specified key with the given value if it is not already associated with a value.
<p>If error occurs during cache access, the method will not throw an exception.</p>
<p>{@link MultiLevelCache} does not support this method.</p>
@param key key with which the specified value is to be associated
@p... | putIfAbsent | java | alibaba/jetcache | jetcache-core/src/main/java/com/alicp/jetcache/Cache.java | https://github.com/alibaba/jetcache/blob/master/jetcache-core/src/main/java/com/alicp/jetcache/Cache.java | Apache-2.0 |
default boolean remove(K key) {
return REMOVE(key).isSuccess();
} | Removes the mapping for a key from this cache if it is present.
<p>If error occurs during cache access, the method will not throw an exception.</p>
@param key key whose mapping is to be removed from the cache
@return true if the key is removed successfully, false if the KV association does not exists in the cache,
... | remove | java | alibaba/jetcache | jetcache-core/src/main/java/com/alicp/jetcache/Cache.java | https://github.com/alibaba/jetcache/blob/master/jetcache-core/src/main/java/com/alicp/jetcache/Cache.java | Apache-2.0 |
@Override
default void close() {
} | Clean resources created by this cache. | close | java | alibaba/jetcache | jetcache-core/src/main/java/com/alicp/jetcache/Cache.java | https://github.com/alibaba/jetcache/blob/master/jetcache-core/src/main/java/com/alicp/jetcache/Cache.java | Apache-2.0 |
@SuppressWarnings("unchecked")
default AutoReleaseLock tryLock(K key, long expire, TimeUnit timeUnit) {
if (key == null) {
return null;
}
final String uuid = UUID.randomUUID().toString();
final long expireTimestamp = System.currentTimeMillis() + timeUnit.toMillis(expire);... | Use this cache attempt to acquire a exclusive lock specified by the key, this method will not block.
examples:
<pre>
try(AutoReleaseLock lock = cache.tryLock("MyKey",100, TimeUnit.SECONDS)){
if(lock != null){
// do something
}
}
</pre>
<p>{@link MultiLevelCache} will use the last level cache to s... | tryLock | java | alibaba/jetcache | jetcache-core/src/main/java/com/alicp/jetcache/Cache.java | https://github.com/alibaba/jetcache/blob/master/jetcache-core/src/main/java/com/alicp/jetcache/Cache.java | Apache-2.0 |
default boolean tryLockAndRun(K key, long expire, TimeUnit timeUnit, Runnable action){
try (AutoReleaseLock lock = tryLock(key, expire, timeUnit)) {
if (lock != null) {
action.run();
return true;
} else {
return false;
}
... | Use this cache to try run an action exclusively.
<p>{@link MultiLevelCache} will use the last level cache to support this operation.</p>
examples:
<pre>
cache.tryLock("MyKey",100, TimeUnit.SECONDS),() -> {
//do something
});
</pre>
@param key lockKey
@param expire lock expire time
@param timeUnit lock expire tim... | tryLockAndRun | java | alibaba/jetcache | jetcache-core/src/main/java/com/alicp/jetcache/Cache.java | https://github.com/alibaba/jetcache/blob/master/jetcache-core/src/main/java/com/alicp/jetcache/Cache.java | Apache-2.0 |
default V computeIfAbsent(K key, Function<K, V> loader) {
return computeIfAbsent(key, loader, config().isCacheNullValue());
} | If there is a value associated with the key, return the value;
otherwise use the loader load the value and return, and then update the cache.
@param key the key
@param loader the value loader
@return the value
@see CacheConfig#isCacheNullValue() | computeIfAbsent | java | alibaba/jetcache | jetcache-core/src/main/java/com/alicp/jetcache/Cache.java | https://github.com/alibaba/jetcache/blob/master/jetcache-core/src/main/java/com/alicp/jetcache/Cache.java | Apache-2.0 |
default void put(K key, V value, long expireAfterWrite, TimeUnit timeUnit) {
PUT(key, value, expireAfterWrite, timeUnit);
} | Associates the specified value with the specified key in the cache.
<p>If error occurs during cache access, the method will not throw an exception.</p>
@param key key with which the specified value is to be associated
@param value value to be associated with the specified key
@param expireAfterWrite the TTL(time to liv... | put | java | alibaba/jetcache | jetcache-core/src/main/java/com/alicp/jetcache/Cache.java | https://github.com/alibaba/jetcache/blob/master/jetcache-core/src/main/java/com/alicp/jetcache/Cache.java | Apache-2.0 |
default CacheResult PUT(K key, V value) {
if (key == null) {
return CacheResult.FAIL_ILLEGAL_ARGUMENT;
}
return PUT(key, value, config().getExpireAfterWriteInMillis(), TimeUnit.MILLISECONDS);
} | Associates the specified value with the specified key in the cache.
<p>if the implementation supports asynchronous operation, the cache access may not completed after this method
return. The invoke of getResultCode()/isSuccess()/getMessage() on the result will block until cache
operation is completed. Call future() met... | PUT | java | alibaba/jetcache | jetcache-core/src/main/java/com/alicp/jetcache/Cache.java | https://github.com/alibaba/jetcache/blob/master/jetcache-core/src/main/java/com/alicp/jetcache/Cache.java | Apache-2.0 |
default void putAll(Map<? extends K, ? extends V> map, long expireAfterWrite, TimeUnit timeUnit) {
PUT_ALL(map, expireAfterWrite, timeUnit);
} | Copies all of the entries from the specified map to the cache.
<p>If error occurs during cache access, the method will not throw an exception.</p>
@param map mappings to be stored in this cache.
@param expireAfterWrite the TTL(time to live) of the KV association
@param timeUnit the time unit of expireAfterWrite
@see #P... | putAll | java | alibaba/jetcache | jetcache-core/src/main/java/com/alicp/jetcache/Cache.java | https://github.com/alibaba/jetcache/blob/master/jetcache-core/src/main/java/com/alicp/jetcache/Cache.java | Apache-2.0 |
default CacheResult PUT_ALL(Map<? extends K, ? extends V> map) {
if (map == null) {
return CacheResult.FAIL_ILLEGAL_ARGUMENT;
}
return PUT_ALL(map, config().getExpireAfterWriteInMillis(), TimeUnit.MILLISECONDS);
} | Copies all of the entries from the specified map to the cache.
<p>if the implementation supports asynchronous operation, the cache access may not completed after this method
return. The invoke of getResultCode()/isSuccess()/getMessage() on the result will block until cache
operation is completed. Call future() method o... | PUT_ALL | java | alibaba/jetcache | jetcache-core/src/main/java/com/alicp/jetcache/Cache.java | https://github.com/alibaba/jetcache/blob/master/jetcache-core/src/main/java/com/alicp/jetcache/Cache.java | Apache-2.0 |
default void putBroadcastManager(BroadcastManager broadcastManager){
putBroadcastManager(CacheConsts.DEFAULT_AREA, broadcastManager);
} | create or get Cache instance.
@see QuickConfig#newBuilder(String) | putBroadcastManager | java | alibaba/jetcache | jetcache-core/src/main/java/com/alicp/jetcache/CacheManager.java | https://github.com/alibaba/jetcache/blob/master/jetcache-core/src/main/java/com/alicp/jetcache/CacheManager.java | Apache-2.0 |
public Cache getCache() {
return cache;
} | The CacheEvent is used in single JVM while CacheMessage used for distributed message.
@author huangli | getCache | java | alibaba/jetcache | jetcache-core/src/main/java/com/alicp/jetcache/event/CacheEvent.java | https://github.com/alibaba/jetcache/blob/master/jetcache-core/src/main/java/com/alicp/jetcache/event/CacheEvent.java | Apache-2.0 |
public long getEpoch() {
return epoch;
} | The CacheEvent is used in single JVM while CacheMessage used for distributed message.
@author huangli | getEpoch | java | alibaba/jetcache | jetcache-core/src/main/java/com/alicp/jetcache/event/CacheEvent.java | https://github.com/alibaba/jetcache/blob/master/jetcache-core/src/main/java/com/alicp/jetcache/event/CacheEvent.java | Apache-2.0 |
@Bean
public RedissonAutoInit redissonAutoInit() {
return new RedissonAutoInit();
} | Created on 2022/7/12.
@author <a href="mailto:jeason1914@qq.com">yangyong</a> | redissonAutoInit | java | alibaba/jetcache | jetcache-starter/jetcache-autoconfigure/src/main/java/com/alicp/jetcache/autoconfigure/RedissonAutoConfiguration.java | https://github.com/alibaba/jetcache/blob/master/jetcache-starter/jetcache-autoconfigure/src/main/java/com/alicp/jetcache/autoconfigure/RedissonAutoConfiguration.java | Apache-2.0 |
@Override
protected CacheBuilder initCache(final ConfigTree ct, final String cacheAreaWithPrefix) {
final Map<String, RedissonClient> beans = this.context.getBeansOfType(RedissonClient.class);
if (beans.isEmpty()) {
throw new CacheConfigException("no RedissonClient in spr... | Created on 2022/7/12.
@author <a href="mailto:jeason1914@qq.com">yangyong</a> | initCache | java | alibaba/jetcache | jetcache-starter/jetcache-autoconfigure/src/main/java/com/alicp/jetcache/autoconfigure/RedissonAutoConfiguration.java | https://github.com/alibaba/jetcache/blob/master/jetcache-starter/jetcache-autoconfigure/src/main/java/com/alicp/jetcache/autoconfigure/RedissonAutoConfiguration.java | Apache-2.0 |
@Override
public void setApplicationContext(final ApplicationContext context) throws BeansException {
this.context = context;
} | Created on 2022/7/12.
@author <a href="mailto:jeason1914@qq.com">yangyong</a> | setApplicationContext | java | alibaba/jetcache | jetcache-starter/jetcache-autoconfigure/src/main/java/com/alicp/jetcache/autoconfigure/RedissonAutoConfiguration.java | https://github.com/alibaba/jetcache/blob/master/jetcache-starter/jetcache-autoconfigure/src/main/java/com/alicp/jetcache/autoconfigure/RedissonAutoConfiguration.java | Apache-2.0 |
@SuppressWarnings("unchecked")
private <C, P, R> R doWithPipeline(C client, boolean pipelineFirst, Function<P, R> function) {
C commands = null;
Closeable closeable = null;
try {
commands = client;
P pipeline = null;
// The connection from JedisPooled or J... | Useful function for redis interaction via Pipeline mode. Resources will be auto close. <br/>
For batch command, such as {@link StringBinaryCommands#mget(byte[]...)}, {@link KeyBinaryCommands#del(byte[]...)}, the performance of pipeline will be worse,
so choose them instead of pipeline as much as possible in non-cluster... | doWithPipeline | java | alibaba/jetcache | jetcache-support/jetcache-redis/src/main/java/com/alicp/jetcache/redis/RedisCache.java | https://github.com/alibaba/jetcache/blob/master/jetcache-support/jetcache-redis/src/main/java/com/alicp/jetcache/redis/RedisCache.java | Apache-2.0 |
private <T> void sync(T pipeline) {
if (pipeline instanceof Pipeline) {
((Pipeline) pipeline).sync();
} else if (pipeline instanceof ClusterPipeline) {
((ClusterPipeline) pipeline).sync();
} else {
throw new UnsupportedOperationException("unrecognized pipeline... | Useful function for redis interaction via Pipeline mode. Resources will be auto close. <br/>
For batch command, such as {@link StringBinaryCommands#mget(byte[]...)}, {@link KeyBinaryCommands#del(byte[]...)}, the performance of pipeline will be worse,
so choose them instead of pipeline as much as possible in non-cluster... | sync | java | alibaba/jetcache | jetcache-support/jetcache-redis/src/main/java/com/alicp/jetcache/redis/RedisCache.java | https://github.com/alibaba/jetcache/blob/master/jetcache-support/jetcache-redis/src/main/java/com/alicp/jetcache/redis/RedisCache.java | Apache-2.0 |
@Override
public void startSubscribe() {
reentrantLock.lock();
try {
if (this.subscribeId == 0 && Objects.nonNull(this.channel) && !this.channel.isEmpty()) {
this.subscribeId = this.client.getTopic(this.channel)
.addListener(byte[].class, (channel,... | Created on 2022/7/12.
@author <a href="mailto:jeason1914@qq.com">yangyong</a> | startSubscribe | java | alibaba/jetcache | jetcache-support/jetcache-redisson/src/main/java/com/alicp/jetcache/redisson/RedissonBroadcastManager.java | https://github.com/alibaba/jetcache/blob/master/jetcache-support/jetcache-redisson/src/main/java/com/alicp/jetcache/redisson/RedissonBroadcastManager.java | Apache-2.0 |
@Override
public void close() {
reentrantLock.lock();
try {
final int id;
if ((id = this.subscribeId) > 0 && Objects.nonNull(this.channel)) {
this.subscribeId = 0;
try {
this.client.getTopic(this.channel).removeListener(id);... | Created on 2022/7/12.
@author <a href="mailto:jeason1914@qq.com">yangyong</a> | close | java | alibaba/jetcache | jetcache-support/jetcache-redisson/src/main/java/com/alicp/jetcache/redisson/RedissonBroadcastManager.java | https://github.com/alibaba/jetcache/blob/master/jetcache-support/jetcache-redisson/src/main/java/com/alicp/jetcache/redisson/RedissonBroadcastManager.java | Apache-2.0 |
@Override
public CacheResult publish(final CacheMessage cacheMessage) {
try {
if (Objects.nonNull(this.channel) && Objects.nonNull(cacheMessage)) {
final byte[] msg = this.config.getValueEncoder().apply(cacheMessage);
this.client.getTopic(this.channel).publish(msg... | Created on 2022/7/12.
@author <a href="mailto:jeason1914@qq.com">yangyong</a> | publish | java | alibaba/jetcache | jetcache-support/jetcache-redisson/src/main/java/com/alicp/jetcache/redisson/RedissonBroadcastManager.java | https://github.com/alibaba/jetcache/blob/master/jetcache-support/jetcache-redisson/src/main/java/com/alicp/jetcache/redisson/RedissonBroadcastManager.java | Apache-2.0 |
protected String getCacheKey(final K key) {
final byte[] newKey = buildKey(key);
return new String(newKey, StandardCharsets.UTF_8);
} | Created on 2022/7/12.
@author <a href="mailto:jeason1914@qq.com">yangyong</a> | getCacheKey | java | alibaba/jetcache | jetcache-support/jetcache-redisson/src/main/java/com/alicp/jetcache/redisson/RedissonCache.java | https://github.com/alibaba/jetcache/blob/master/jetcache-support/jetcache-redisson/src/main/java/com/alicp/jetcache/redisson/RedissonCache.java | Apache-2.0 |
@Override
public CacheConfig<K, V> config() {
return this.config;
} | Created on 2022/7/12.
@author <a href="mailto:jeason1914@qq.com">yangyong</a> | config | java | alibaba/jetcache | jetcache-support/jetcache-redisson/src/main/java/com/alicp/jetcache/redisson/RedissonCache.java | https://github.com/alibaba/jetcache/blob/master/jetcache-support/jetcache-redisson/src/main/java/com/alicp/jetcache/redisson/RedissonCache.java | Apache-2.0 |
@Override
public <T> T unwrap(final Class<T> clazz) {
throw new UnsupportedOperationException("RedissonCache does not support unwrap");
} | Created on 2022/7/12.
@author <a href="mailto:jeason1914@qq.com">yangyong</a> | unwrap | java | alibaba/jetcache | jetcache-support/jetcache-redisson/src/main/java/com/alicp/jetcache/redisson/RedissonCache.java | https://github.com/alibaba/jetcache/blob/master/jetcache-support/jetcache-redisson/src/main/java/com/alicp/jetcache/redisson/RedissonCache.java | Apache-2.0 |
private Codec getCodec() {
return ByteArrayCodec.INSTANCE;
} | Created on 2022/7/12.
@author <a href="mailto:jeason1914@qq.com">yangyong</a> | getCodec | java | alibaba/jetcache | jetcache-support/jetcache-redisson/src/main/java/com/alicp/jetcache/redisson/RedissonCache.java | https://github.com/alibaba/jetcache/blob/master/jetcache-support/jetcache-redisson/src/main/java/com/alicp/jetcache/redisson/RedissonCache.java | Apache-2.0 |
private byte[] encoder(final CacheValueHolder<V> holder) {
if (Objects.nonNull(holder)) {
return valueEncoder.apply(holder);
}
return null;
} | Created on 2022/7/12.
@author <a href="mailto:jeason1914@qq.com">yangyong</a> | encoder | java | alibaba/jetcache | jetcache-support/jetcache-redisson/src/main/java/com/alicp/jetcache/redisson/RedissonCache.java | https://github.com/alibaba/jetcache/blob/master/jetcache-support/jetcache-redisson/src/main/java/com/alicp/jetcache/redisson/RedissonCache.java | Apache-2.0 |
@SuppressWarnings({"unchecked"})
private CacheValueHolder<V> decoder(final K key, final byte[] data, final int counter) {
CacheValueHolder<V> holder = null;
if (Objects.nonNull(data) && data.length > 0) {
try {
holder = (CacheValueHolder<V>) valueDecoder.apply(data);
... | Created on 2022/7/12.
@author <a href="mailto:jeason1914@qq.com">yangyong</a> | decoder | java | alibaba/jetcache | jetcache-support/jetcache-redisson/src/main/java/com/alicp/jetcache/redisson/RedissonCache.java | https://github.com/alibaba/jetcache/blob/master/jetcache-support/jetcache-redisson/src/main/java/com/alicp/jetcache/redisson/RedissonCache.java | Apache-2.0 |
private CacheValueHolder<V> decoder(final K key, final byte[] data) {
return decoder(key, data, 0);
} | Created on 2022/7/12.
@author <a href="mailto:jeason1914@qq.com">yangyong</a> | decoder | java | alibaba/jetcache | jetcache-support/jetcache-redisson/src/main/java/com/alicp/jetcache/redisson/RedissonCache.java | https://github.com/alibaba/jetcache/blob/master/jetcache-support/jetcache-redisson/src/main/java/com/alicp/jetcache/redisson/RedissonCache.java | Apache-2.0 |
private CacheValueHolder<V> compatibleOldVal(final K key, final byte[] data, final int counter) {
if (Objects.nonNull(key) && Objects.nonNull(data) && data.length > 0 && counter <= 1) {
try {
final Codec codec = this.client.getConfig().getCodec();
if (Objects.nonNull(... | Created on 2022/7/12.
@author <a href="mailto:jeason1914@qq.com">yangyong</a> | compatibleOldVal | java | alibaba/jetcache | jetcache-support/jetcache-redisson/src/main/java/com/alicp/jetcache/redisson/RedissonCache.java | https://github.com/alibaba/jetcache/blob/master/jetcache-support/jetcache-redisson/src/main/java/com/alicp/jetcache/redisson/RedissonCache.java | Apache-2.0 |
@Override
@SuppressWarnings({"unchecked"})
protected CacheGetResult<V> do_GET(final K key) {
try {
final RBucket<byte[]> rb = this.client.getBucket(getCacheKey(key), getCodec());
final CacheValueHolder<V> holder = decoder(key, rb.get());
if (Objects.nonNull(holder)) {... | Created on 2022/7/12.
@author <a href="mailto:jeason1914@qq.com">yangyong</a> | do_GET | java | alibaba/jetcache | jetcache-support/jetcache-redisson/src/main/java/com/alicp/jetcache/redisson/RedissonCache.java | https://github.com/alibaba/jetcache/blob/master/jetcache-support/jetcache-redisson/src/main/java/com/alicp/jetcache/redisson/RedissonCache.java | Apache-2.0 |
@Override
@SuppressWarnings({"unchecked"})
protected MultiGetResult<K, V> do_GET_ALL(final Set<? extends K> keys) {
try {
final Map<K, CacheGetResult<V>> retMap = new HashMap<>(1 << 4);
if (Objects.nonNull(keys) && !keys.isEmpty()) {
final Map<K, String> keyMap = ... | Created on 2022/7/12.
@author <a href="mailto:jeason1914@qq.com">yangyong</a> | do_GET_ALL | java | alibaba/jetcache | jetcache-support/jetcache-redisson/src/main/java/com/alicp/jetcache/redisson/RedissonCache.java | https://github.com/alibaba/jetcache/blob/master/jetcache-support/jetcache-redisson/src/main/java/com/alicp/jetcache/redisson/RedissonCache.java | Apache-2.0 |
@Override
protected CacheResult do_PUT(final K key, final V value, final long expireAfterWrite, final TimeUnit timeUnit) {
try {
final CacheValueHolder<V> holder = new CacheValueHolder<>(value, timeUnit.toMillis(expireAfterWrite));
this.client.getBucket(getCacheKey(key), getCodec()).... | Created on 2022/7/12.
@author <a href="mailto:jeason1914@qq.com">yangyong</a> | do_PUT | java | alibaba/jetcache | jetcache-support/jetcache-redisson/src/main/java/com/alicp/jetcache/redisson/RedissonCache.java | https://github.com/alibaba/jetcache/blob/master/jetcache-support/jetcache-redisson/src/main/java/com/alicp/jetcache/redisson/RedissonCache.java | Apache-2.0 |
@Override
protected CacheResult do_PUT_ALL(final Map<? extends K, ? extends V> map, final long expireAfterWrite, final TimeUnit timeUnit) {
try {
if (Objects.nonNull(map) && !map.isEmpty()) {
final long expire = timeUnit.toMillis(expireAfterWrite);
final RBatch ba... | Created on 2022/7/12.
@author <a href="mailto:jeason1914@qq.com">yangyong</a> | do_PUT_ALL | java | alibaba/jetcache | jetcache-support/jetcache-redisson/src/main/java/com/alicp/jetcache/redisson/RedissonCache.java | https://github.com/alibaba/jetcache/blob/master/jetcache-support/jetcache-redisson/src/main/java/com/alicp/jetcache/redisson/RedissonCache.java | Apache-2.0 |
@Override
protected CacheResult do_REMOVE(final K key) {
try {
final boolean ret = this.client.getBucket(getCacheKey(key), getCodec()).delete();
return ret ? CacheResult.SUCCESS_WITHOUT_MSG : CacheResult.FAIL_WITHOUT_MSG;
} catch (Throwable e) {
logError("REMOVE",... | Created on 2022/7/12.
@author <a href="mailto:jeason1914@qq.com">yangyong</a> | do_REMOVE | java | alibaba/jetcache | jetcache-support/jetcache-redisson/src/main/java/com/alicp/jetcache/redisson/RedissonCache.java | https://github.com/alibaba/jetcache/blob/master/jetcache-support/jetcache-redisson/src/main/java/com/alicp/jetcache/redisson/RedissonCache.java | Apache-2.0 |
@Override
protected CacheResult do_REMOVE_ALL(final Set<? extends K> keys) {
try {
if (Objects.nonNull(keys) && !keys.isEmpty()) {
final RBatch batch = this.client.createBatch();
keys.forEach(key -> batch.getBucket(getCacheKey(key), getCodec()).deleteAsync());
... | Created on 2022/7/12.
@author <a href="mailto:jeason1914@qq.com">yangyong</a> | do_REMOVE_ALL | java | alibaba/jetcache | jetcache-support/jetcache-redisson/src/main/java/com/alicp/jetcache/redisson/RedissonCache.java | https://github.com/alibaba/jetcache/blob/master/jetcache-support/jetcache-redisson/src/main/java/com/alicp/jetcache/redisson/RedissonCache.java | Apache-2.0 |
@Override
protected CacheResult do_PUT_IF_ABSENT(final K key, final V value, final long expireAfterWrite, final TimeUnit timeUnit) {
try {
final Duration expire = Duration.ofMillis(timeUnit.toMillis(expireAfterWrite));
final CacheValueHolder<V> holder = new CacheValueHolder<>(value, ... | Created on 2022/7/12.
@author <a href="mailto:jeason1914@qq.com">yangyong</a> | do_PUT_IF_ABSENT | java | alibaba/jetcache | jetcache-support/jetcache-redisson/src/main/java/com/alicp/jetcache/redisson/RedissonCache.java | https://github.com/alibaba/jetcache/blob/master/jetcache-support/jetcache-redisson/src/main/java/com/alicp/jetcache/redisson/RedissonCache.java | Apache-2.0 |
public static RedissonDataCacheBuilderImpl createBuilder() {
return new RedissonDataCacheBuilderImpl();
} | Created on 2022/7/12.
@author <a href="mailto:jeason1914@qq.com">yangyong</a> | createBuilder | java | alibaba/jetcache | jetcache-support/jetcache-redisson/src/main/java/com/alicp/jetcache/redisson/RedissonCacheBuilder.java | https://github.com/alibaba/jetcache/blob/master/jetcache-support/jetcache-redisson/src/main/java/com/alicp/jetcache/redisson/RedissonCacheBuilder.java | Apache-2.0 |
@Override
@SuppressWarnings({"all"})
public RedissonCacheConfig getConfig() {
if (this.config == null) {
this.config = new RedissonCacheConfig();
}
return (RedissonCacheConfig) this.config;
} | Created on 2022/7/12.
@author <a href="mailto:jeason1914@qq.com">yangyong</a> | getConfig | java | alibaba/jetcache | jetcache-support/jetcache-redisson/src/main/java/com/alicp/jetcache/redisson/RedissonCacheBuilder.java | https://github.com/alibaba/jetcache/blob/master/jetcache-support/jetcache-redisson/src/main/java/com/alicp/jetcache/redisson/RedissonCacheBuilder.java | Apache-2.0 |
public T redissonClient(final RedissonClient client) {
this.getConfig().setRedissonClient(client);
return self();
} | Created on 2022/7/12.
@author <a href="mailto:jeason1914@qq.com">yangyong</a> | redissonClient | java | alibaba/jetcache | jetcache-support/jetcache-redisson/src/main/java/com/alicp/jetcache/redisson/RedissonCacheBuilder.java | https://github.com/alibaba/jetcache/blob/master/jetcache-support/jetcache-redisson/src/main/java/com/alicp/jetcache/redisson/RedissonCacheBuilder.java | Apache-2.0 |
@Override
public boolean supportBroadcast() {
return true;
} | Created on 2022/7/12.
@author <a href="mailto:jeason1914@qq.com">yangyong</a> | supportBroadcast | java | alibaba/jetcache | jetcache-support/jetcache-redisson/src/main/java/com/alicp/jetcache/redisson/RedissonCacheBuilder.java | https://github.com/alibaba/jetcache/blob/master/jetcache-support/jetcache-redisson/src/main/java/com/alicp/jetcache/redisson/RedissonCacheBuilder.java | Apache-2.0 |
@Override
public BroadcastManager createBroadcastManager(final CacheManager cacheManager) {
final RedissonCacheConfig<?, ?> c = (RedissonCacheConfig<?, ?>) this.getConfig().clone();
return new RedissonBroadcastManager(cacheManager, c);
} | Created on 2022/7/12.
@author <a href="mailto:jeason1914@qq.com">yangyong</a> | createBroadcastManager | java | alibaba/jetcache | jetcache-support/jetcache-redisson/src/main/java/com/alicp/jetcache/redisson/RedissonCacheBuilder.java | https://github.com/alibaba/jetcache/blob/master/jetcache-support/jetcache-redisson/src/main/java/com/alicp/jetcache/redisson/RedissonCacheBuilder.java | Apache-2.0 |
public RedissonClient getRedissonClient() {
return redissonClient;
} | Created on 2022/7/12.
@author <a href="mailto:jeason1914@qq.com">yangyong</a> | getRedissonClient | java | alibaba/jetcache | jetcache-support/jetcache-redisson/src/main/java/com/alicp/jetcache/redisson/RedissonCacheConfig.java | https://github.com/alibaba/jetcache/blob/master/jetcache-support/jetcache-redisson/src/main/java/com/alicp/jetcache/redisson/RedissonCacheConfig.java | Apache-2.0 |
public void setRedissonClient(final RedissonClient redissonClient) {
this.redissonClient = redissonClient;
} | Created on 2022/7/12.
@author <a href="mailto:jeason1914@qq.com">yangyong</a> | setRedissonClient | java | alibaba/jetcache | jetcache-support/jetcache-redisson/src/main/java/com/alicp/jetcache/redisson/RedissonCacheConfig.java | https://github.com/alibaba/jetcache/blob/master/jetcache-support/jetcache-redisson/src/main/java/com/alicp/jetcache/redisson/RedissonCacheConfig.java | Apache-2.0 |
private static void penetrationProtectTestWithComputeIfAbsent(Cache cache) throws Exception {
String keyPrefix = "penetrationProtect_";
AtomicInteger loadSuccess = new AtomicInteger(0);
Function loader = new Function() {
private AtomicInteger count1 = new AtomicInteger(0);
... | This unit test case verifies that for a single key, only one thread can enter.
@param cache
@throws Exception | penetrationProtectTestWithComputeIfAbsent | java | alibaba/jetcache | jetcache-test/src/main/java/com/alicp/jetcache/test/AbstractCacheTest.java | https://github.com/alibaba/jetcache/blob/master/jetcache-test/src/main/java/com/alicp/jetcache/test/AbstractCacheTest.java | Apache-2.0 |
@Override
public Object apply(Object k) {
try {
Thread.sleep(100);
} catch (InterruptedException e) {
throw new RuntimeException(e);
}
if ((keyPrefix + "1").equals(k)) {
// fail 2 time... | This unit test case verifies that for a single key, only one thread can enter.
@param cache
@throws Exception | apply | java | alibaba/jetcache | jetcache-test/src/main/java/com/alicp/jetcache/test/AbstractCacheTest.java | https://github.com/alibaba/jetcache/blob/master/jetcache-test/src/main/java/com/alicp/jetcache/test/AbstractCacheTest.java | Apache-2.0 |
private static void penetrationProtectTestWithLoadingCache(Cache cache) throws Exception {
String failMsg[] = new String[1];
Function<Integer, Integer> loaderFunction = new Function<Integer, Integer>() {
ConcurrentHashMap<Integer, Integer> map = new ConcurrentHashMap<>();
@Over... | This unit test case verifies that for a single key, only one thread can enter.
@param cache
@throws Exception | penetrationProtectTestWithLoadingCache | java | alibaba/jetcache | jetcache-test/src/main/java/com/alicp/jetcache/test/AbstractCacheTest.java | https://github.com/alibaba/jetcache/blob/master/jetcache-test/src/main/java/com/alicp/jetcache/test/AbstractCacheTest.java | Apache-2.0 |
@Override
public Integer apply(Integer key) {
try {
Thread.sleep(50);
} catch (InterruptedException e) {
throw new RuntimeException(e);
}
if (map.get(key) == null) {
map.put(key, key);... | This unit test case verifies that for a single key, only one thread can enter.
@param cache
@throws Exception | apply | java | alibaba/jetcache | jetcache-test/src/main/java/com/alicp/jetcache/test/AbstractCacheTest.java | https://github.com/alibaba/jetcache/blob/master/jetcache-test/src/main/java/com/alicp/jetcache/test/AbstractCacheTest.java | Apache-2.0 |
private static void penetrationProtectReEntryTest(Cache cache) {
Object v = cache.computeIfAbsent("penetrationProtectReEntryTest",
(k) -> cache.computeIfAbsent(k, (k2) -> "V"));
Assert.assertEquals("V", v);
} | This unit test case verifies that for a single key, only one thread can enter.
@param cache
@throws Exception | penetrationProtectReEntryTest | java | alibaba/jetcache | jetcache-test/src/main/java/com/alicp/jetcache/test/AbstractCacheTest.java | https://github.com/alibaba/jetcache/blob/master/jetcache-test/src/main/java/com/alicp/jetcache/test/AbstractCacheTest.java | Apache-2.0 |
private static void penetrationProtectTimeoutTest(Cache cache) throws Exception {
String keyPrefix = "penetrationProtectTimeoutTest_";
final Duration SHORT_PROTECT_DURATION = Duration.ofMillis(1);
final Duration LONG_PROTECT_DURATION = Duration.ofSeconds(60);
cache.config().setPenetratio... | This unit test case verifies that for a single key, only one thread can enter.
@param cache
@throws Exception | penetrationProtectTimeoutTest | java | alibaba/jetcache | jetcache-test/src/main/java/com/alicp/jetcache/test/AbstractCacheTest.java | https://github.com/alibaba/jetcache/blob/master/jetcache-test/src/main/java/com/alicp/jetcache/test/AbstractCacheTest.java | Apache-2.0 |
@Test
public void tests() throws Exception {
System.setProperty("spring.profiles.active", "redisson");
context = SpringApplication.run(RedissonStarterTest.class);
doTest();
} | Created on 2022/7/13.
@author <a href="mailto:jeason1914@qq.com">yangyong</a> | tests | java | alibaba/jetcache | jetcache-test/src/test/java/com/alicp/jetcache/autoconfigure/RedissonStarterTest.java | https://github.com/alibaba/jetcache/blob/master/jetcache-test/src/test/java/com/alicp/jetcache/autoconfigure/RedissonStarterTest.java | Apache-2.0 |
@PostConstruct
public void test() {
Assert.assertTrue(cache.PUT("K", "V").isSuccess());
} | Created on 2022/7/13.
@author <a href="mailto:jeason1914@qq.com">yangyong</a> | test | java | alibaba/jetcache | jetcache-test/src/test/java/com/alicp/jetcache/autoconfigure/RedissonStarterTest.java | https://github.com/alibaba/jetcache/blob/master/jetcache-test/src/test/java/com/alicp/jetcache/autoconfigure/RedissonStarterTest.java | Apache-2.0 |
@Bean(name = "factoryBeanTarget")
public MyFactoryBean factoryBean() {
return new MyFactoryBean();
} | Created on 2022/7/13.
@author <a href="mailto:jeason1914@qq.com">yangyong</a> | factoryBean | java | alibaba/jetcache | jetcache-test/src/test/java/com/alicp/jetcache/autoconfigure/RedissonStarterTest.java | https://github.com/alibaba/jetcache/blob/master/jetcache-test/src/test/java/com/alicp/jetcache/autoconfigure/RedissonStarterTest.java | Apache-2.0 |
@Before
public void initRedissonClient() {
final Config config = new Config();
config.useSingleServer().setAddress("redis://127.0.0.1:6379").setDatabase(0);
this.client = Redisson.create(config);
} | Created on 2022/7/15.
@author <a href="mailto:jeason1914@qq.com">yangyong</a> | initRedissonClient | java | alibaba/jetcache | jetcache-test/src/test/java/com/alicp/jetcache/redisson/RedissonBroadcastManagerTest.java | https://github.com/alibaba/jetcache/blob/master/jetcache-test/src/test/java/com/alicp/jetcache/redisson/RedissonBroadcastManagerTest.java | Apache-2.0 |
@After
public void closeRedissonClient() {
this.client.shutdown();
} | Created on 2022/7/15.
@author <a href="mailto:jeason1914@qq.com">yangyong</a> | closeRedissonClient | java | alibaba/jetcache | jetcache-test/src/test/java/com/alicp/jetcache/redisson/RedissonBroadcastManagerTest.java | https://github.com/alibaba/jetcache/blob/master/jetcache-test/src/test/java/com/alicp/jetcache/redisson/RedissonBroadcastManagerTest.java | Apache-2.0 |
@Test
public void redissonTest() throws Exception {
final BroadcastManager bm = RedissonCacheBuilder.createBuilder()
.redissonClient(client)
.keyConvertor(FastjsonKeyConvertor.INSTANCE)
.valueEncoder(JavaValueEncoder.INSTANCE)
.valueDecoder(Jav... | Created on 2022/7/15.
@author <a href="mailto:jeason1914@qq.com">yangyong</a> | redissonTest | java | alibaba/jetcache | jetcache-test/src/test/java/com/alicp/jetcache/redisson/RedissonBroadcastManagerTest.java | https://github.com/alibaba/jetcache/blob/master/jetcache-test/src/test/java/com/alicp/jetcache/redisson/RedissonBroadcastManagerTest.java | Apache-2.0 |
@Test
public void redissonTest() throws Exception {
final Config config = new Config();
config.useSingleServer().setAddress("redis://127.0.0.1:6379").setDatabase(0);
doTest(Redisson.create(config));
} | Created on 2022/7/13.
@author <a href="mailto:jeason1914@qq.com">yangyong</a> | redissonTest | java | alibaba/jetcache | jetcache-test/src/test/java/com/alicp/jetcache/redisson/RedissonCacheTest.java | https://github.com/alibaba/jetcache/blob/master/jetcache-test/src/test/java/com/alicp/jetcache/redisson/RedissonCacheTest.java | Apache-2.0 |
private void doTest(final RedissonClient redissonClient) throws Exception {
cache = RedissonCacheBuilder.createBuilder()
.keyConvertor(FastjsonKeyConvertor.INSTANCE)
.valueEncoder(JavaValueEncoder.INSTANCE)
.valueDecoder(JavaValueDecoder.INSTANCE)
... | Created on 2022/7/13.
@author <a href="mailto:jeason1914@qq.com">yangyong</a> | doTest | java | alibaba/jetcache | jetcache-test/src/test/java/com/alicp/jetcache/redisson/RedissonCacheTest.java | https://github.com/alibaba/jetcache/blob/master/jetcache-test/src/test/java/com/alicp/jetcache/redisson/RedissonCacheTest.java | Apache-2.0 |
public void ressetStartAt() {
this.start = System.currentTimeMillis();
} | Help class for sleep, Constructor with a base time interval in milliseconds, the start time will
be set to the current time.
<p>
The sleepTo method sleeps to particular time point of any multiple of interval from the start time. | ressetStartAt | java | alibaba/jetcache | jetcache-test/src/test/java/com/alicp/jetcache/testsupport/Sleeper.java | https://github.com/alibaba/jetcache/blob/master/jetcache-test/src/test/java/com/alicp/jetcache/testsupport/Sleeper.java | Apache-2.0 |
public void sleepTo(double ratio) throws InterruptedException {
long wakeup = (long) (start + ratio * refresh);
Thread.sleep(wakeup - System.currentTimeMillis());
} | Help class for sleep, Constructor with a base time interval in milliseconds, the start time will
be set to the current time.
<p>
The sleepTo method sleeps to particular time point of any multiple of interval from the start time. | sleepTo | java | alibaba/jetcache | jetcache-test/src/test/java/com/alicp/jetcache/testsupport/Sleeper.java | https://github.com/alibaba/jetcache/blob/master/jetcache-test/src/test/java/com/alicp/jetcache/testsupport/Sleeper.java | Apache-2.0 |
public static void main(String[] args) {
Config config = new Config();
config.useSingleServer().setAddress("redis://127.0.0.1:6379").setDatabase(0);
Cache<String, String> cache = RedissonCacheBuilder.createBuilder()
.redissonClient(Redisson.create(config))
.keyCon... | @author <a href="mailto:etczyp@qq.com">zhangyaoping</a> | main | java | alibaba/jetcache | samples/simple-samples/src/main/java/RedissonExample.java | https://github.com/alibaba/jetcache/blob/master/samples/simple-samples/src/main/java/RedissonExample.java | Apache-2.0 |
@Nullable
static List<Tile> generatePremadeMap() {
if (!DEBUG_ENABLED) {
return null;
}
if (PREMADE_MAP == null) {
return null;
}
List<Tile> result = new ArrayList<>();
for (int yy = 0; yy < PREMADE_MAP.length; yy++) {
for (int xx... | Tools and hooks for debugging.
Note to self: when making a custom build, set the versionCode in
installed/build.gradle to 1. | generatePremadeMap | java | tpcstld/2048 | 2048/base/src/main/java/com/tpcstld/twozerogame/DebugTools.java | https://github.com/tpcstld/2048/blob/master/2048/base/src/main/java/com/tpcstld/twozerogame/DebugTools.java | MIT |
static long getStartingScore() {
if (!DEBUG_ENABLED) {
return 0;
}
return STARTING_SCORE;
} | Tools and hooks for debugging.
Note to self: when making a custom build, set the versionCode in
installed/build.gradle to 1. | getStartingScore | java | tpcstld/2048 | 2048/base/src/main/java/com/tpcstld/twozerogame/DebugTools.java | https://github.com/tpcstld/2048/blob/master/2048/base/src/main/java/com/tpcstld/twozerogame/DebugTools.java | MIT |
private void signInToGoogle() {
SharedPreferences settings = PreferenceManager.getDefaultSharedPreferences(this);
final boolean noLoginPrompt = settings.getBoolean(NO_LOGIN_PROMPT, false);
GoogleSignInOptions signInOptions =
new GoogleSignInOptions.Builder(GoogleSignInOptions.DEF... | Signs into Google. Used for cloud saves. | signInToGoogle | java | tpcstld/2048 | 2048/base/src/main/java/com/tpcstld/twozerogame/MainActivity.java | https://github.com/tpcstld/2048/blob/master/2048/base/src/main/java/com/tpcstld/twozerogame/MainActivity.java | MIT |
@Override
public void onComplete(@NonNull Task<GoogleSignInAccount> task) {
if (!task.isSuccessful()) {
if (!firstLoginAttempt && !noLoginPrompt) {
firstLoginAttempt = true;
startActivityForResult(signInClient.getSignInInten... | Signs into Google. Used for cloud saves. | onComplete | java | tpcstld/2048 | 2048/base/src/main/java/com/tpcstld/twozerogame/MainActivity.java | https://github.com/tpcstld/2048/blob/master/2048/base/src/main/java/com/tpcstld/twozerogame/MainActivity.java | MIT |
@Override
public void run(@NonNull SnapshotData data) {
view.game.handleSnapshot(data);
} | Signs into Google. Used for cloud saves. | run | java | tpcstld/2048 | 2048/base/src/main/java/com/tpcstld/twozerogame/MainActivity.java | https://github.com/tpcstld/2048/blob/master/2048/base/src/main/java/com/tpcstld/twozerogame/MainActivity.java | MIT |
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if (requestCode != RC_SIGN_IN) {
return;
}
GoogleSignInResult result = Auth.GoogleSignInApi.getSignInResultFromIntent(data);
... | Signs into Google. Used for cloud saves. | onActivityResult | java | tpcstld/2048 | 2048/base/src/main/java/com/tpcstld/twozerogame/MainActivity.java | https://github.com/tpcstld/2048/blob/master/2048/base/src/main/java/com/tpcstld/twozerogame/MainActivity.java | MIT |
@Override
public void run(@NonNull SnapshotData data) {
view.game.handleSnapshot(data);
} | Signs into Google. Used for cloud saves. | run | java | tpcstld/2048 | 2048/base/src/main/java/com/tpcstld/twozerogame/MainActivity.java | https://github.com/tpcstld/2048/blob/master/2048/base/src/main/java/com/tpcstld/twozerogame/MainActivity.java | MIT |
public static void loadSnapshot(Context context, final Callback callback) {
GoogleSignInAccount account = GoogleSignIn.getLastSignedInAccount(context);
if (account != null) {
SnapshotsClient snapshotsClient = Games.getSnapshotsClient(context, account);
snapshotsClient.open(FILE_N... | Manages the Google Cloud Save snapshot. | loadSnapshot | java | tpcstld/2048 | 2048/base/src/main/java/com/tpcstld/twozerogame/snapshot/SnapshotManager.java | https://github.com/tpcstld/2048/blob/master/2048/base/src/main/java/com/tpcstld/twozerogame/snapshot/SnapshotManager.java | MIT |
@Override
public void onComplete(@NonNull Task<SnapshotsClient.DataOrConflict<Snapshot>> task) {
Snapshot snapshot = getSnapshotFromTask(task);
if (snapshot == null) {
return;
}
... | Manages the Google Cloud Save snapshot. | onComplete | java | tpcstld/2048 | 2048/base/src/main/java/com/tpcstld/twozerogame/snapshot/SnapshotManager.java | https://github.com/tpcstld/2048/blob/master/2048/base/src/main/java/com/tpcstld/twozerogame/snapshot/SnapshotManager.java | MIT |
public static void saveSnapshot(@NonNull Context context, @NonNull final SnapshotData data) {
lastSnapshot = data;
GoogleSignInAccount account = GoogleSignIn.getLastSignedInAccount(context);
if (account != null) {
if (saveInProgress) {
return;
}
... | Manages the Google Cloud Save snapshot. | saveSnapshot | java | tpcstld/2048 | 2048/base/src/main/java/com/tpcstld/twozerogame/snapshot/SnapshotManager.java | https://github.com/tpcstld/2048/blob/master/2048/base/src/main/java/com/tpcstld/twozerogame/snapshot/SnapshotManager.java | MIT |
@Override
public void onComplete(@NonNull Task<SnapshotsClient.DataOrConflict<Snapshot>> task) {
saveInProgress = false;
Snapshot snapshot = getSnapshotFromTask(task);
if (snapshot == null) {
... | Manages the Google Cloud Save snapshot. | onComplete | java | tpcstld/2048 | 2048/base/src/main/java/com/tpcstld/twozerogame/snapshot/SnapshotManager.java | https://github.com/tpcstld/2048/blob/master/2048/base/src/main/java/com/tpcstld/twozerogame/snapshot/SnapshotManager.java | MIT |
private static Snapshot getSnapshotFromTask(Task<SnapshotsClient.DataOrConflict<Snapshot>> task) {
if (!task.isSuccessful()) {
return null;
}
if (task.getResult() == null) {
return null;
}
return task.getResult().getData();
} | Manages the Google Cloud Save snapshot. | getSnapshotFromTask | java | tpcstld/2048 | 2048/base/src/main/java/com/tpcstld/twozerogame/snapshot/SnapshotManager.java | https://github.com/tpcstld/2048/blob/master/2048/base/src/main/java/com/tpcstld/twozerogame/snapshot/SnapshotManager.java | MIT |
public Drawable getMarker() {
return mMarker;
} | Return the Drawable use as this {@link Annotation}'s marker or null if
none have been set.
@return The marker {@link Drawable} | getMarker | java | cyrilmottier/Polaris | library/src/com/cyrilmottier/polaris/Annotation.java | https://github.com/cyrilmottier/Polaris/blob/master/library/src/com/cyrilmottier/polaris/Annotation.java | Apache-2.0 |
@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}
final CoordinateRegion region = (CoordinateRegion) o;
return latitude == region.latitude && longitude == ... | Create a new region, initialized with the values in the specified region
(which is left unmodified).
@param region The region whose coordinates are copied into this region. | equals | java | cyrilmottier/Polaris | library/src/com/cyrilmottier/polaris/CoordinateRegion.java | https://github.com/cyrilmottier/Polaris/blob/master/library/src/com/cyrilmottier/polaris/CoordinateRegion.java | Apache-2.0 |
@Override
public int hashCode() {
int result = latitude;
result = 31 * result + longitude;
result = 31 * result + latitudeSpan;
result = 31 * result + longitudeSpan;
return result;
} | Create a new region, initialized with the values in the specified region
(which is left unmodified).
@param region The region whose coordinates are copied into this region. | hashCode | java | cyrilmottier/Polaris | library/src/com/cyrilmottier/polaris/CoordinateRegion.java | https://github.com/cyrilmottier/Polaris/blob/master/library/src/com/cyrilmottier/polaris/CoordinateRegion.java | Apache-2.0 |
@Override
public String toString() {
StringBuilder sb = new StringBuilder(32);
sb.append("CoordinateRegion(");
sb.append(latitude);
sb.append(", ");
sb.append(longitude);
sb.append(" - ");
sb.append(latitudeSpan);
sb.append(", ");
sb.append(lon... | Create a new region, initialized with the values in the specified region
(which is left unmodified).
@param region The region whose coordinates are copied into this region. | toString | java | cyrilmottier/Polaris | library/src/com/cyrilmottier/polaris/CoordinateRegion.java | https://github.com/cyrilmottier/Polaris/blob/master/library/src/com/cyrilmottier/polaris/CoordinateRegion.java | Apache-2.0 |
public void set(int latitude, int longitude, int latitudeSpan, int longitudeSpan) {
this.latitude = latitude;
this.longitude = longitude;
this.latitudeSpan = latitudeSpan;
this.longitudeSpan = longitudeSpan;
} | Set the {@link CoordinateRegion} to the specified values. Note: no range
checking is performed, so it is up to the caller to ensure that latitude,
longitude, latitudeSpan and longitudeSpan are valid.
@param latitude The latitude of the region
@param longitude The longitude of the region
@param latitudeSpan The span on... | set | java | cyrilmottier/Polaris | library/src/com/cyrilmottier/polaris/CoordinateRegion.java | https://github.com/cyrilmottier/Polaris/blob/master/library/src/com/cyrilmottier/polaris/CoordinateRegion.java | Apache-2.0 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.