Examples of ICacheable


Examples of org.red5.server.api.cache.ICacheable

      // log.debug("Softreference: " + (null == tmp));
      // if (null != tmp) {
      // log.debug("Softreference value: " + (null == tmp.get()));
      // }
      if (null == tmp || null == tmp.get()) {
        ICacheable cacheable = null;
        if (obj instanceof ICacheable) {
          cacheable = (ICacheable) obj;
        } else {
          cacheable = new CacheableImpl(obj);
        }
        // set the objects name
        cacheable.setName(name);
        // set a registry entry
        registry.put(name, 1);
        // create a soft reference
        SoftReference<ICacheable> value = new SoftReference<ICacheable>(
            cacheable);
View Full Code Here

Examples of org.red5.server.api.cache.ICacheable

  /** {@inheritDoc} */
    public ICacheable get(String name) {
    if (log.isDebugEnabled()) {
      log.debug("Looking up " + name + " in the cache. Current size: " + CACHE.size());
    }
    ICacheable ic = null;
    SoftReference sr = null;
    if (!CACHE.isEmpty() && null != (sr = CACHE.get(name))) {
      ic = (ICacheable) sr.get();
      // add a request count to the registry
      int requestCount = registry.get(name);
View Full Code Here

Examples of org.red5.server.api.cache.ICacheable

    }
  }

  /** {@inheritDoc} */
    public ICacheable get(String name) {
    ICacheable ic = null;
    try {
      ic = (ICacheable) cache.get(name).getObjectValue();
    } catch (NullPointerException npe) {
    }
    return ic;
View Full Code Here

Examples of org.red5.server.api.cache.ICacheable

    if (cache == null) {
      System.out.println("No cache");
      log
          .warn("FLV cache is null, an NPE may be thrown. To fix your code, ensure a cache is set via Spring or by the following: setCache(NoCacheImpl.getInstance())");
    }
    ICacheable ic = cache.get(fileName);

    // look in the cache before reading the file from the disk
    if (null == ic || (null == ic.getByteBuffer())) {
      if (file.exists()) {
        if (log.isDebugEnabled()) {
          log.debug("File size: " + file.length());
        }
        reader = new FLVReader(file, generateMetadata);
        // get a ref to the mapped byte buffer
        fileData = reader.getFileData();
        // offer the uncached file to the cache
        if (fileData != null && cache.offer(fileName, fileData)) {
          if (log.isDebugEnabled()) {
            log.debug("Item accepted by the cache: " + fileName);
          }
        } else {
          if (log.isDebugEnabled()) {
            log.debug("Item will not be cached: " + fileName);
          }
        }
      } else {
        log.info("Creating new file: " + file);
        file.createNewFile();
      }
    } else {
      fileData = ByteBuffer.wrap(ic.getBytes());
      reader = new FLVReader(fileData, generateMetadata);
    }
    return reader;
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.