code: public static long putFromByteArray(Cache cache, String resource, byte [] data) throws CacheException {
  		if(cache == null) {
  			logger.error("cache reference must not be null");
  			throw new CacheException("invalid cache");
  		}
  		ByteArrayInputStream input = null;
  		OutputStream output = null;
  		try { 
  			output = cache.put(resource);
  			if(output != null) {
  				input = new ByteArrayInputStream(data);
  				long copied = Streams.copy(input, output);
  				logger.trace("copied {} bytes into cache", copied);
  				return copied;
  			}			
  		} catch (IOException e) {
  			logger.error("error copying data from byte array to cache", e);
  			throw new CacheException("error copying data from byte array to cache", e);
  		} finally {
  			Streams.safelyClose(input);
  			Streams.safelyClose(output);
  		}
  		return -1;
  	}
docs: Stores the given array of bytes under the given resource name.
  
  @param cache
  the cache that stores the resource.
  @param resource
  the name of the resource to be stored.
  @param data
  the array of bytes containing the resource.
  @return
  the number of bytes copied to the cache.
  @throws CacheException