Package javax.cache

Examples of javax.cache.CacheFactory


    try {
      @SuppressWarnings("rawtypes")
      Map props = new HashMap();
      props.put(GCacheFactory.EXPIRATION_DELTA, 3600*24); // cache expires in one day
      CacheFactory cacheFactory = CacheManager.getInstance().getCacheFactory();
      cache = cacheFactory.createCache(props);
    } catch (CacheException e) {
      log.severe("Error initialising station storage. Cache is not used!: " + e.toString());
    }
  }
View Full Code Here


    try {
      @SuppressWarnings("rawtypes")
      Map props = new HashMap();
      props.put(GCacheFactory.EXPIRATION_DELTA, 3600*24); // cache expires in one day
      CacheFactory cacheFactory = CacheManager.getInstance().getCacheFactory();
      cache = cacheFactory.createCache(props);
    } catch (CacheException e) {
      log.severe("Error initialising station storage. Cache is not used!: " + e.toString());
    }
  }
View Full Code Here

    private static final Logger log = Logger.getLogger(MediaFactory.class.getName());
    Cache cache;

  public MediaFactory() {
      try {
          CacheFactory cacheFactory = CacheManager.getInstance().getCacheFactory();
          cache = cacheFactory.createCache(Collections.emptyMap());
      } catch (CacheException e) {
          log.severe(e.getMessage());
      }
  }
View Full Code Here

   * Constructs an instance of the cache.
   * @throws CacheException If there is a problem connecting to Google App
   *     Engine Memcache.
   */
  public WaveSubmittedTweetsCache() throws CacheException {
    CacheFactory cacheFactory = CacheManager.getInstance().getCacheFactory();
    this.cache = cacheFactory.createCache(Collections.emptyMap());
  }
View Full Code Here

      Cache cache;
      HashMap<String, Object> object;
      try {
        // log.log(level, "1");
        CacheFactory cacheFactory = CacheManager.getInstance()
            .getCacheFactory();
        // log.log(level, "2");
        cache = cacheFactory.createCache(Collections.emptyMap());
        // log.log(level, "3");
        // Get the value from the cache.
        object = (HashMap<String, Object>) cache.get(clazz
            + Long.toString(id));
        // log.log(level, "4");
        if (object != null) {

          // log.log(level, "found " + clazz + " " + id +
          // " in memcache");
          return object;
        }
        // log.info("did not find " + clazz + " " + id +
        // " in memcache");
      } catch (CacheException e) {
        e.printStackTrace();
        // log.log(Level.WARNING, e.getMessage());
      }

      DatastoreService datastore = DatastoreServiceFactory
          .getDatastoreService();
      object = new HashMap<String, Object>();
      try {
        Entity e = datastore.get(KeyFactory.createKey(clazz, id));
        // properties
        for (Entry<String, Object> entry : e.getProperties().entrySet()) {
          Object value = entry.getValue();
          if (value instanceof Text) {
            object.put(entry.getKey(), ((Text) value).getValue());
          } else if (value instanceof String) {
            object.put(entry.getKey(), ((String) value));
          } else {
            object.put(entry.getKey(), value);
          }
        }
        object.put("id", Long.toString(e.getKey().getId()));

        try {
          // log.log(level, "1");
          CacheFactory cacheFactory = CacheManager.getInstance()
              .getCacheFactory();
          // log.log(level, "2");
          cache = cacheFactory.createCache(Collections.emptyMap());
          // log.log(level, "3");
          cache.put(clazz + id, object);
          // log.info("put " + clazz + " " + id + " in memcache");
        } catch (CacheException ce) {
          // exception handling
View Full Code Here

    // consultar si el resultado est� en la cache
    try {
      Map<Integer, Integer> props = new HashMap<Integer, Integer>();
      props.put(GCacheFactory.EXPIRATION_DELTA, 1800);
      CacheFactory cacheFactory = CacheManager.getInstance().getCacheFactory();
      Cache cache = cacheFactory.createCache(Collections.emptyMap());

      List<FeaturedArticle> articles = (List<FeaturedArticle>) cache.get(FEATURED_ARTICLES_KEY);

      if (articles == null) {
        // si no esta, buscar los 5 art�culos con m�s comentarios
View Full Code Here

            return cache;

        Map config = createConfig(name);
        Map wrappedConfig = new HashMap(config);
        wrappedConfig.put("cache-name", name);
        CacheFactory factory = manager.getCacheFactory();
        cache = factory.createCache(wrappedConfig);
        manager.registerCache(name, cache);
        return cache;
    }
View Full Code Here

          startsWith, orderBy, false);

      // Try to get the memcache
      if (cache == null) {
        try {
          CacheFactory cacheFactory = CacheManager.getInstance().getCacheFactory();
          cache = cacheFactory.createCache(Collections.emptyMap());
        } catch (CacheException e) {
          log.warning("Exception retrieving memcache instance: " + e);
        }
      }
View Full Code Here

          orderBy, false);

      // Try to get the memcache
      if (cache == null) {
        try {
          CacheFactory cacheFactory = CacheManager.getInstance().getCacheFactory();
          cache = cacheFactory.createCache(Collections.emptyMap());
        } catch (CacheException e) {
          log.warning("Exception retrieving memcache instance: " + e);
        }
      }
View Full Code Here

 
  @SuppressWarnings("unchecked")
  public void setImage(Image image) {
    if (image != null) {
      try {
        CacheFactory cacheFactory = CacheManager.getInstance().getCacheFactory();
        Cache cache = cacheFactory.createCache(Collections.emptyMap());
        cache.put(value, image);
      } catch (CacheException e) {
        logger.error(e.getMessage(), e);
      }
    } else if (value != null) {
View Full Code Here

TOP

Related Classes of javax.cache.CacheFactory

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.