是整个mapstate示例或mapstate中每个元素的flink mapstate的ttl

d4so4syb  于 2021-06-24  发布在  Flink
关注(0)|答案(1)|浏览(813)

我在Flink有个Map州。我把ttl设置为10分钟。ttl是针对整个mapstate示例还是针对每个元素?

val ttlConfig = StateTtlConfig
      .newBuilder(Time.minutes(10))
      .setUpdateType(StateTtlConfig.UpdateType.OnCreateAndWrite)
      .setStateVisibility(StateTtlConfig.StateVisibility.NeverReturnExpired)
      .build

      val myMapState: MapState[String, Upload] = ....

      myMapState.put("a", "x")

      // 5 minutes later
      myMapState.put("b", "y")

      // Again 6 minutes later, is the myMapState still available? 
      // I assume myMapState is still available and it still has key "b" for 4 minutes. Is that correct?
41ik7eoe

41ik7eoe1#

嗨,你的假设是正确的。
如果配置了ttl并且状态值已过期,则将尽最大努力清除存储的值。
因此,即使ttl已通过,也可能仍会存储该值,状态可见性配置将控制是否返回该值。
statettlconfig.statevisibility.neverreturnexpired-从不返回过期值
statettlconfig.statevisibility.ReturnExpireDefNotCleanedUp-如果仍然可用,则返回
有关州ttl的详细信息

相关问题