コード例 #1
0
ファイル: DiskStore.java プロジェクト: martenscs/ehmem
  /**
   * Creates a disk store.
   *
   * @param cache the {@link net.sf.ehcache.Cache} that the store is part of
   * @param diskPath the directory in which to create data and index files
   */
  public DiskStore(Ehcache cache, String diskPath) {
    status = Status.STATUS_UNINITIALISED;
    this.cache = cache;
    name = cache.getName();
    this.diskPath = diskPath;
    expiryThreadInterval = cache.getDiskExpiryThreadIntervalSeconds();
    persistent = cache.isDiskPersistent();
    maxElementsOnDisk = cache.getMaxElementsOnDisk();
    eternal = cache.isEternal();
    diskSpoolBufferSizeBytes =
        cache.getCacheConfiguration().getDiskSpoolBufferSizeMB() * ONE_MEGABYTE;

    try {
      initialiseFiles();

      active = true;

      // Always start up the spool thread
      spoolAndExpiryThread = new SpoolAndExpiryThread();
      spoolAndExpiryThread.start();

      status = Status.STATUS_ALIVE;
    } catch (final Exception e) {
      // Cleanup on error
      dispose();
      LOG.error(
          name + "Cache: Could not create disk store. Initial cause was " + e.getMessage(), e);
    }
  }