@@ -58,6 +58,7 @@ impl InMemoryStore {
5858 let outer_e = persisted_lock. entry ( prefixed. clone ( ) ) . or_insert ( HashMap :: new ( ) ) ;
5959 outer_e. insert ( key. to_string ( ) , buf) ;
6060
61+ // Only assign creation time on first write (not on update)
6162 let mut ct_lock = self . creation_times . lock ( ) . unwrap ( ) ;
6263 let ct_ns = ct_lock. entry ( prefixed) . or_insert ( HashMap :: new ( ) ) ;
6364 ct_ns
@@ -77,6 +78,7 @@ impl InMemoryStore {
7778 outer_ref. remove ( & key. to_string ( ) ) ;
7879 }
7980
81+ // Remove creation time entry
8082 let mut ct_lock = self . creation_times . lock ( ) . unwrap ( ) ;
8183 if let Some ( ct_ns) = ct_lock. get_mut ( & prefixed) {
8284 ct_ns. remove ( key) ;
@@ -105,21 +107,18 @@ impl KVStore for InMemoryStore {
105107 let res = self . read_internal ( & primary_namespace, & secondary_namespace, & key) ;
106108 async move { res }
107109 }
108-
109110 fn write (
110111 & self , primary_namespace : & str , secondary_namespace : & str , key : & str , buf : Vec < u8 > ,
111112 ) -> impl Future < Output = Result < ( ) , io:: Error > > + ' static + Send {
112113 let res = self . write_internal ( & primary_namespace, & secondary_namespace, & key, buf) ;
113114 async move { res }
114115 }
115-
116116 fn remove (
117117 & self , primary_namespace : & str , secondary_namespace : & str , key : & str , lazy : bool ,
118118 ) -> impl Future < Output = Result < ( ) , io:: Error > > + ' static + Send {
119119 let res = self . remove_internal ( & primary_namespace, & secondary_namespace, & key, lazy) ;
120120 async move { res }
121121 }
122-
123122 fn list (
124123 & self , primary_namespace : & str , secondary_namespace : & str ,
125124 ) -> impl Future < Output = Result < Vec < String > , io:: Error > > + ' static + Send {
@@ -166,9 +165,11 @@ impl InMemoryStore {
166165 } ,
167166 } ;
168167
168+ // Build list of (key, sort_order) sorted by sort_order DESC (newest first).
169169 let mut entries: Vec < ( & String , & u64 ) > = ct_ns. iter ( ) . collect ( ) ;
170170 entries. sort_by ( |a, b| b. 1 . cmp ( a. 1 ) ) ;
171171
172+ // Apply page token filter
172173 let start_idx = if let Some ( ref token) = page_token {
173174 let token_sort_order: u64 = token
174175 . as_str ( )
@@ -183,6 +184,7 @@ impl InMemoryStore {
183184 0
184185 } ;
185186
187+ // Fetch one extra entry beyond page size to determine whether a next page exists.
186188 let mut page: Vec < ( & String , & u64 ) > =
187189 entries[ start_idx..] . iter ( ) . take ( IN_MEMORY_PAGE_SIZE + 1 ) . cloned ( ) . collect ( ) ;
188190
0 commit comments