Exemplo n.º 1
0
  public boolean compare(String mapName, Object value1, Object value2) {
    if (value1 == null && value2 == null) {
      return true;
    }
    if (value1 == null) {
      return false;
    }
    if (value2 == null) {
      return false;
    }

    MapContainer mapContainer = getMapContainer(mapName);
    return mapContainer.getRecordFactory().isEquals(value1, value2);
  }
Exemplo n.º 2
0
  public Record createRecord(
      String name, Data dataKey, Object value, long ttl, boolean shouldSchedule) {
    MapContainer mapContainer = getMapContainer(name);
    Record record = mapContainer.getRecordFactory().newRecord(dataKey, value);

    if (shouldSchedule) {
      // if ttl is 0 then no eviction. if ttl is -1 then default configured eviction is applied
      if (ttl < 0 && mapContainer.getMapConfig().getTimeToLiveSeconds() > 0) {
        scheduleTtlEviction(
            name, record, mapContainer.getMapConfig().getTimeToLiveSeconds() * 1000);
      } else if (ttl > 0) {
        scheduleTtlEviction(name, record, ttl);
      }
      if (mapContainer.getMapConfig().getMaxIdleSeconds() > 0) {
        scheduleIdleEviction(name, dataKey, mapContainer.getMapConfig().getMaxIdleSeconds() * 1000);
      }
    }
    return record;
  }