[ https://issues.apache.org/jira/browse/GEODE-8864?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17294217#comment-17294217 ]
ASF GitHub Bot commented on GEODE-8864: --------------------------------------- sabbey37 commented on a change in pull request #5954: URL: https://github.com/apache/geode/pull/5954#discussion_r586040291 ########## File path: geode-redis/src/main/java/org/apache/geode/redis/internal/data/RedisHash.java ########## @@ -46,19 +53,88 @@ public class RedisHash extends AbstractRedisData { public static final RedisHash NULL_REDIS_HASH = new NullRedisHash(); private HashMap<ByteArrayWrapper, ByteArrayWrapper> hash; + private ConcurrentHashMap<UUID, List<ByteArrayWrapper>> hScanSnapShots; + private ConcurrentHashMap<UUID, Long> hScanSnapShotCreationTimes; + private ScheduledExecutorService HSCANSnapshotExpirationExecutor = null; + + private static int default_hscan_snapshots_expire_check_frequency = + Integer.getInteger("redis.hscan-snapshot-cleanup-interval", 30000); + + private static int default_hscan_snapshots_milliseconds_to_live = + Integer.getInteger("redis.hscan-snapshot-expiry", 30000); + + private int HSCAN_SNAPSHOTS_EXPIRE_CHECK_FREQUENCY_MILLISECONDS; + private int MINIMUM_MILLISECONDS_FOR_HSCAN_SNAPSHOTS_TO_LIVE; + + @VisibleForTesting + public RedisHash(List<ByteArrayWrapper> fieldsToSet, int hscanSnapShotExpirationCheckFrequency, + int minimumLifeForHscanSnaphot) { + this(); + + this.HSCAN_SNAPSHOTS_EXPIRE_CHECK_FREQUENCY_MILLISECONDS = + hscanSnapShotExpirationCheckFrequency; + this.MINIMUM_MILLISECONDS_FOR_HSCAN_SNAPSHOTS_TO_LIVE = minimumLifeForHscanSnaphot; - public RedisHash(List<ByteArrayWrapper> fieldsToSet) { - hash = new HashMap<>(); Iterator<ByteArrayWrapper> iterator = fieldsToSet.iterator(); while (iterator.hasNext()) { hashPut(iterator.next(), iterator.next()); } } + public RedisHash(List<ByteArrayWrapper> fieldsToSet) { + this(fieldsToSet, + default_hscan_snapshots_expire_check_frequency, + default_hscan_snapshots_milliseconds_to_live); + } + + // for serialization public RedisHash() { - // for serialization + this.hash = new HashMap<>(); + this.hScanSnapShots = new ConcurrentHashMap<>(); + this.hScanSnapShotCreationTimes = new ConcurrentHashMap<>(); + + this.HSCAN_SNAPSHOTS_EXPIRE_CHECK_FREQUENCY_MILLISECONDS = + this.default_hscan_snapshots_expire_check_frequency; + + this.MINIMUM_MILLISECONDS_FOR_HSCAN_SNAPSHOTS_TO_LIVE = + this.default_hscan_snapshots_milliseconds_to_live; } + + private void expireHScanSnapshots() { + + this.hScanSnapShotCreationTimes.entrySet().forEach(entry -> { Review comment: I was confused for a second, but then realized the above comment went with the comment that was in the `createKeySnapshot` method. Those changes look good! The conversation didn't propagate to this area, so here it is: ``` @sabbey37 You could actually do this.hScanSnapShotCreationTimes.forEach((entry, creationTime) -> {...}, that way you wouldn't have to do the entry.getValue(); on the next line. Not necessary, just something cool IntelliJ suggested. Tip @jhutchison o, wow- that's because I'm not making a copy like I thought I was- changed to this: List keySnapShot = new ArrayList<>(); List hashKeysAsList = Arrays.asList(hash.keySet().toArray()); Collections.copy(keySnapShot, hashKeysAsList); ``` ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org > finish implementation of Redis HScan Command > -------------------------------------------- > > Key: GEODE-8864 > URL: https://issues.apache.org/jira/browse/GEODE-8864 > Project: Geode > Issue Type: New Feature > Components: redis > Reporter: John Hutchison > Priority: Major > Labels: blocks-1.14.0, pull-request-available > -- This message was sent by Atlassian Jira (v8.3.4#803005)