本文整理汇总了Java中com.google.appengine.api.memcache.MemcacheService.SetPolicy类的典型用法代码示例。如果您正苦于以下问题:Java SetPolicy类的具体用法?Java SetPolicy怎么用?Java SetPolicy使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
SetPolicy类属于com.google.appengine.api.memcache.MemcacheService包,在下文中一共展示了SetPolicy类的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: getCount
import com.google.appengine.api.memcache.MemcacheService.SetPolicy; //导入依赖的package包/类
/**
* Retrieve the value of this sharded counter.
*
* @return Summed total of all shards' counts
*/
public long getCount() {
Long value = (Long) mc.get(kind);
if (value != null) {
return value;
}
long sum = 0;
Query query = new Query(kind);
for (Entity shard : ds.prepare(query).asIterable()) {
sum += (Long) shard.getProperty(CounterShard.COUNT);
}
mc.put(kind, sum, Expiration.byDeltaSeconds(60),
SetPolicy.ADD_ONLY_IF_NOT_PRESENT);
return sum;
}
开发者ID:GoogleCloudPlatform,项目名称:appengine-sharded-counters-java-maven,代码行数:22,代码来源:ShardedCounter.java
示例2: getCount
import com.google.appengine.api.memcache.MemcacheService.SetPolicy; //导入依赖的package包/类
/**
* Retrieve the value of this sharded counter.
*
* @return Summed total of all shards' counts
*/
public final long getCount() {
Long value = (Long) mc.get(kind);
if (value != null) {
return value;
}
long sum = 0;
Query query = new Query(kind);
for (Entity shard : DS.prepare(query).asIterable()) {
sum += (Long) shard.getProperty(CounterShard.COUNT);
}
mc.put(kind, sum, Expiration.byDeltaSeconds(CACHE_PERIOD),
SetPolicy.ADD_ONLY_IF_NOT_PRESENT);
return sum;
}
开发者ID:GoogleCloudPlatform,项目名称:appengine-sharded-counters-java,代码行数:22,代码来源:ShardedCounter.java
示例3: put
import com.google.appengine.api.memcache.MemcacheService.SetPolicy; //导入依赖的package包/类
/**
* @return true if a new entry was created, false if not because of the
* policy.
*/
public boolean put(@Nullable K key, @Nullable V value, @Nullable Expiration expires,
SetPolicy policy) {
TaggedKey<K> taggedKey = tagKey(key);
String expiresString = expires == null ? null : "" + expires.getMillisecondsValue();
log.info("cache put " + taggedKey + " = " + value + ", " + expiresString + ", " + policy);
return service.put(taggedKey, value, expires, policy);
}
开发者ID:ArloJamesBarnes,项目名称:walkaround,代码行数:12,代码来源:MemcacheTable.java
示例4: putAll
import com.google.appengine.api.memcache.MemcacheService.SetPolicy; //导入依赖的package包/类
/**
* @return the set of keys for which new entries were created (some may not
* have been created because of the policy).
*/
public Set<K> putAll(Map<K, V> mappings, @Nullable Expiration expires, SetPolicy policy) {
Map<TaggedKey<K>, V> rawMappings = Maps.newHashMapWithExpectedSize(mappings.size());
for (Map.Entry<K, V> entry : mappings.entrySet()) {
rawMappings.put(tagKey(entry.getKey()), entry.getValue());
}
Set<TaggedKey<K>> rawResult = service.putAll(rawMappings, expires, policy);
Set<K> result = Sets.newHashSetWithExpectedSize(rawResult.size());
for (TaggedKey<K> key : rawResult) {
result.add(key.getKey());
}
return result;
}
开发者ID:ArloJamesBarnes,项目名称:walkaround,代码行数:17,代码来源:MemcacheTable.java
示例5: put
import com.google.appengine.api.memcache.MemcacheService.SetPolicy; //导入依赖的package包/类
/**
* @return true if a new entry was created, false if not because of the policy.
*/
public boolean put(@Nullable K key, @Nullable V value, @Nullable Expiration expires,
SetPolicy policy) {
TaggedKey<K> taggedKey = tagKey(key);
String expiresString = expires == null ? null : "" + expires.getMillisecondsValue();
log.info("cache put " + taggedKey + " = " + value + ", " + expiresString + ", " + policy);
return service.put(taggedKey, value, expires, policy);
}
开发者ID:larrytin,项目名称:realtime-server-appengine,代码行数:11,代码来源:MemcacheTable.java
示例6: putAll
import com.google.appengine.api.memcache.MemcacheService.SetPolicy; //导入依赖的package包/类
/**
* @return the set of keys for which new entries were created (some may not have been created
* because of the policy).
*/
public Set<K> putAll(Map<K, V> mappings, @Nullable Expiration expires, SetPolicy policy) {
Map<TaggedKey<K>, V> rawMappings = Maps.newHashMapWithExpectedSize(mappings.size());
for (Map.Entry<K, V> entry : mappings.entrySet()) {
rawMappings.put(tagKey(entry.getKey()), entry.getValue());
}
Set<TaggedKey<K>> rawResult = service.putAll(rawMappings, expires, policy);
Set<K> result = Sets.newHashSetWithExpectedSize(rawResult.size());
for (TaggedKey<K> key : rawResult) {
result.add(key.getKey());
}
return result;
}
开发者ID:larrytin,项目名称:realtime-server-appengine,代码行数:17,代码来源:MemcacheTable.java
示例7: serverFor
import com.google.appengine.api.memcache.MemcacheService.SetPolicy; //导入依赖的package包/类
/**
* Returns and maybe creates a mapping to a server for the given object id.
*
* @return the mapped server, and true if that mapping already existed, false
* if it was created by this method.
*
* WARNING: if a mapping could not be established, returns null.
*/
@Nullable
private Pair<Boolean, Integer> serverFor(SlobId objectId) {
boolean wasMapped;
int serverId;
Integer maybeServerId = objectServerMappings.get(objectId);
if (maybeServerId != null) {
wasMapped = true;
serverId = maybeServerId;
monitoring.incrementCounter("affinity-mapping-found");
} else {
int newServerId = random.nextInt(numStoreServers);
int expiration = AFFINITY_MIN_EXPIRATION_SECONDS
+ random.nextInt(AFFINITY_EXPIRATION_SPREAD_SECONDS);
log.info("No mapping for " + objectId + ", generated " + newServerId +
", expiration " + expiration);
boolean putSucceeded = objectServerMappings.put(objectId, newServerId,
Expiration.byDeltaSeconds(expiration),
SetPolicy.ADD_ONLY_IF_NOT_PRESENT);
if (putSucceeded) {
serverId = newServerId;
wasMapped = false;
monitoring.incrementCounter("affinity-mapping-generated");
} else {
log.warning("Mapping was generated concurrently");
maybeServerId = objectServerMappings.get(objectId);
if (maybeServerId != null) {
serverId = maybeServerId;
wasMapped = true;
monitoring.incrementCounter("affinity-mapping-generated-but-overwritten");
} else {
log.warning("Concurrently generated mapping promptly disappeared!");
monitoring.incrementCounter("affinity-mapping-generated-but-lost");
return null;
}
}
}
return Pair.of(wasMapped, serverId);
}
开发者ID:ArloJamesBarnes,项目名称:walkaround,代码行数:49,代码来源:AffinityMutationProcessor.java
示例8: serverFor
import com.google.appengine.api.memcache.MemcacheService.SetPolicy; //导入依赖的package包/类
/**
* Returns and maybe creates a mapping to a server for the given object id.
*
* @return the mapped server, and true if that mapping already existed, false if it was created by
* this method.
*
* WARNING: if a mapping could not be established, returns null.
*/
@Nullable
private Pair<Boolean, Integer> serverFor(ObjectId objectId) {
boolean wasMapped;
int serverId;
Integer maybeServerId = objectServerMappings.get(objectId);
if (maybeServerId != null) {
wasMapped = true;
serverId = maybeServerId;
monitoring.incrementCounter("affinity-mapping-found");
} else {
int newServerId = random.nextInt(numStoreServers);
int expiration =
AFFINITY_MIN_EXPIRATION_SECONDS + random.nextInt(AFFINITY_EXPIRATION_SPREAD_SECONDS);
log.info("No mapping for " + objectId + ", generated " + newServerId + ", expiration "
+ expiration);
boolean putSucceeded =
objectServerMappings.put(objectId, newServerId, Expiration.byDeltaSeconds(expiration),
SetPolicy.ADD_ONLY_IF_NOT_PRESENT);
if (putSucceeded) {
serverId = newServerId;
wasMapped = false;
monitoring.incrementCounter("affinity-mapping-generated");
} else {
log.warning("Mapping was generated concurrently");
maybeServerId = objectServerMappings.get(objectId);
if (maybeServerId != null) {
serverId = maybeServerId;
wasMapped = true;
monitoring.incrementCounter("affinity-mapping-generated-but-overwritten");
} else {
log.warning("Concurrently generated mapping promptly disappeared!");
monitoring.incrementCounter("affinity-mapping-generated-but-lost");
return null;
}
}
}
return Pair.of(wasMapped, serverId);
}
开发者ID:larrytin,项目名称:realtime-server-appengine,代码行数:49,代码来源:AffinityMutationProcessor.java
注:本文中的com.google.appengine.api.memcache.MemcacheService.SetPolicy类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论