Tagged articles
15 articles
Page 1 of 1
Cognitive Technology Team
Cognitive Technology Team
Sep 25, 2025 · Backend Development

How to Accurately Count Valid Entries in Redisson RMapCache

This article explains why Redisson's RMapCache.size() includes expired entries, demonstrates how to obtain the exact number of currently valid key‑value pairs using keySet().size() or readAllEntrySet().size(), and provides performance tips and a real‑world e‑commerce use case.

Cache MonitoringJavaRMapCache
0 likes · 10 min read
How to Accurately Count Valid Entries in Redisson RMapCache
Architecture Digest
Architecture Digest
Nov 21, 2023 · Backend Development

Understanding Why HashMap.keySet() Traverses Twice in Java

This article explains the internal mechanics of HashMap traversal in Java, comparing iterator, keySet, entrySet and stream approaches, and reveals why using keySet results in two passes—once to obtain an iterator and once to fetch values—by examining the underlying KeySet, KeyIterator, and HashIterator implementations.

HashMapIteratorJava
0 likes · 8 min read
Understanding Why HashMap.keySet() Traverses Twice in Java
Java Architect Essentials
Java Architect Essentials
Nov 16, 2023 · Backend Development

Why Does HashMap.keySet() Iterate Twice? Uncovering Java’s Internal Iterator Mechanics

This article explains why iterating a Java HashMap with keySet() results in two traversals, detailing the internal iterator creation, the role of KeyIterator and HashIterator classes, and how the do‑while loop in HashIterator’s constructor locates the first entry, with code examples and bytecode analysis.

HashIteratorHashMapIterator
0 likes · 9 min read
Why Does HashMap.keySet() Iterate Twice? Uncovering Java’s Internal Iterator Mechanics
Top Architect
Top Architect
Jul 23, 2022 · Backend Development

Four Methods to Traverse a Java Map Using keySet, entrySet and Iterators

This article demonstrates four practical ways to iterate over a Java HashMap—including enhanced for loops with keySet(), iterator-based loops with keySet(), enhanced for loops with entrySet(), and iterator-based loops with entrySet()—and provides a complete example that filters employee objects by salary, complete with full source code.

BackendCollectionsHashMap
0 likes · 10 min read
Four Methods to Traverse a Java Map Using keySet, entrySet and Iterators