• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java SetPolicy类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了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;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java ErrorHandlerProxy类代码示例发布时间:2022-05-23
下一篇:
Java FilterOption类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap