@@ -653,7 +653,7 @@ int hashTypeGetValue(robj *o, sds field, unsigned char **vstr, unsigned int *vle
653653int hashTypeGetExpiry (robj * o , sds field , long long * expiry ) {
654654 if (o -> encoding == OBJ_ENCODING_LISTPACK ) {
655655 if (hashTypeExists (o , field )) {
656- if (expiry ) * expiry = -1 ;
656+ if (expiry ) * expiry = EXPIRY_NONE ;
657657 return C_OK ;
658658 }
659659 } else if (o -> encoding == OBJ_ENCODING_HASHTABLE ) {
@@ -1177,20 +1177,22 @@ robj *hashTypeDup(robj *o) {
11771177 } else if (o -> encoding == OBJ_ENCODING_HASHTABLE ) {
11781178 hashtable * ht = hashtableCreate (& hashHashtableType );
11791179 hashtableExpand (ht , hashtableSize ((const hashtable * )o -> ptr ));
1180+ hobj = createObject (OBJ_HASH , ht );
1181+ hobj -> encoding = OBJ_ENCODING_HASHTABLE ;
11801182
11811183 hashTypeInitIterator (o , & hi );
11821184 while (hashTypeNext (& hi ) != C_ERR ) {
11831185 /* Extract a field-value pair from an original hash object.*/
11841186 sds field = hashTypeCurrentFromHashTable (& hi , OBJ_HASH_FIELD );
11851187 sds value = hashTypeCurrentFromHashTable (& hi , OBJ_HASH_VALUE );
1186-
1188+ long long expiry = hashTypeEntryGetExpiry ( hi . next );
11871189 /* Add a field-value pair to a new hash object. */
1188- hashTypeEntry * entry = hashTypeCreateEntry (field , sdsdup (value ), EXPIRY_NONE );
1190+ hashTypeEntry * entry = hashTypeCreateEntry (field , sdsdup (value ), expiry );
11891191 hashtableAdd (ht , entry );
1192+ if (expiry != EXPIRY_NONE )
1193+ hashTypeTrackEntry (hobj , entry );
11901194 }
11911195 hashTypeResetIterator (& hi );
1192- hobj = createObject (OBJ_HASH , ht );
1193- hobj -> encoding = OBJ_ENCODING_HASHTABLE ;
11941196 } else {
11951197 serverPanic ("Unknown hash encoding" );
11961198 }
0 commit comments