コード例 #1
0
  /**
   * Returns the cached entity.
   *
   * @return true if the cached value is valid.
   */
  @Override
  public Entity loadEntity(AmberConnection aConn, int loadGroup) {
    long now = CurrentTime.getCurrentTime();

    if (_expireTime < now) {
      _expireTime = now + _home.getCacheTimeout();
      _cacheEntity.__caucho_expire();
    }

    try {
      // jpa/0v33
      // Prepared statements are cached per context so
      // at this point, the cache item needs to use the
      // context connection.

      // _cacheEntity.__caucho_setConnection(aConn);
      _cacheEntity.__caucho_retrieve_self(aConn);
    } finally {
      // After loading the entity, all prepared statements
      // were properly cached into the context connection.
      // Now make the cached entity item independent
      // from any particular context.
      _cacheEntity.__caucho_setConnection(null);
    }

    return _cacheEntity;
  }
コード例 #2
0
  /**
   * Returns the cached entity.
   *
   * @return true if the cached value is valid.
   */
  public Entity getEntity() {
    long now = CurrentTime.getCurrentTime();

    if (_expireTime < now) {
      long timeout = _home.getCacheTimeout();

      boolean isExpired = _expireTime > 0 && timeout > 0;

      _expireTime = now + timeout;

      if (isExpired) _cacheEntity.__caucho_expire();
    }

    return _cacheEntity;
  }
コード例 #3
0
  /**
   * Returns the cached entity.
   *
   * @return true if the cached value is valid.
   */
  @Override
  public Entity loadEntity(int loadGroup) {
    long now = CurrentTime.getCurrentTime();

    if (_expireTime < now) {
      _expireTime = now + _home.getCacheTimeout();
      _cacheEntity.__caucho_expire();
    }

    AmberConnection aConn = _home.getManager().getCacheConnection();

    try {
      // _cacheEntity.__caucho_setConnection(aConn);
      _cacheEntity.__caucho_retrieve_self(aConn);
    } finally {
      aConn.freeConnection();
    }

    return _cacheEntity;
  }
コード例 #4
0
 /** Expire the value from the cache. */
 @Override
 public void expire() {
   _cacheEntity.__caucho_expire();
 }