@valkey/valkey-glide 2.0.0 → 2.1.0-rc2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,8 +1,9 @@
1
+ import * as net from "net";
1
2
  import { Buffer, Writer } from "protobufjs/minimal";
2
3
  import { AggregationType, BaseScanOptions, BitFieldGet, // eslint-disable-line @typescript-eslint/no-unused-vars
3
4
  BitFieldSubCommands, // eslint-disable-line @typescript-eslint/no-unused-vars
4
5
  BitOffsetOptions, BitwiseOperation, Boundary, ConnectionError, ExpireOptions, GeoAddOptions, // eslint-disable-line @typescript-eslint/no-unused-vars
5
- GeoSearchResultOptions, GeoSearchShape, GeoSearchStoreResultOptions, GeoUnit, GeospatialData, GlideClientConfiguration, GlideClusterClientConfiguration, HScanOptions, InsertPosition, KeyWeight, LPosOptions, ListDirection, RangeByIndex, RangeByLex, RangeByScore, RequestError, RestoreOptions, Routes, ScoreFilter, Script, SearchOrigin, SetOptions, SortOptions, StreamAddOptions, StreamClaimOptions, StreamGroupOptions, StreamPendingOptions, StreamReadGroupOptions, StreamReadOptions, StreamTrimOptions, TimeUnit, ValkeyError, ZAddOptions, ZScanOptions } from ".";
6
+ GeoSearchResultOptions, GeoSearchShape, GeoSearchStoreResultOptions, GeoUnit, GeospatialData, GlideClientConfiguration, GlideClusterClientConfiguration, HExpireOptions, HGetExOptions, HScanOptions, HSetExOptions, InsertPosition, KeyWeight, LPosOptions, ListDirection, RangeByIndex, RangeByLex, RangeByScore, RequestError, RestoreOptions, Routes, ScoreFilter, Script, SearchOrigin, SetOptions, SortOptions, StreamAddOptions, StreamClaimOptions, StreamGroupOptions, StreamPendingOptions, StreamReadGroupOptions, StreamReadOptions, StreamTrimOptions, TimeUnit, ValkeyError, ZAddOptions, ZScanOptions } from ".";
6
7
  import { command_request, connection_request, response } from "../build-ts/ProtobufMessage";
7
8
  type PromiseFunction = (value?: any) => void;
8
9
  type ErrorFunction = (error: ValkeyError) => void;
@@ -146,6 +147,13 @@ export type ReadFrom =
146
147
  * - **Standalone Mode**: In standalone mode, only the provided nodes will be used.
147
148
  * - **Lazy Connect**: Set `lazyConnect` to `true` to defer connection establishment until the first command is sent.
148
149
  *
150
+ * ### Database Selection
151
+ *
152
+ * - **Database ID**: Use `databaseId` to specify which logical database to connect to (0-15 by default).
153
+ * - **Cluster Mode**: Requires Valkey 9.0+ with multi-database cluster mode enabled.
154
+ * - **Standalone Mode**: Works with all Valkey versions.
155
+ * - **Reconnection**: Database selection persists across reconnections.
156
+ *
149
157
  * ### Security Settings
150
158
  *
151
159
  * - **TLS**: Enable secure communication using `useTLS`.
@@ -182,7 +190,7 @@ export type ReadFrom =
182
190
  * - **Reconnection Strategy**: Customize how the client should attempt reconnections using `connectionBackoff`.
183
191
  * - `numberOfRetries`: The maximum number of retry attempts with increasing delays.
184
192
  * - After this limit is reached, the retry interval becomes constant.
185
- * - `factor`: A multiplier applied to the base delay between retries (e.g., `500` means a 500ms base delay).
193
+ * - `factor`: A multiplier applied to the base delay between retries, specified in milliseconds (e.g., `500` means a 500ms base delay).
186
194
  * - `exponentBase`: The exponential growth factor for delays (e.g., `2` means the delay doubles with each retry).
187
195
  * - `jitterPercent`: An optional percentage of jitter to add to the delay (e.g., `30` means the final delay will vary randomly between 70% and 130% of the calculated delay).
188
196
  *
@@ -193,6 +201,7 @@ export type ReadFrom =
193
201
  * { host: 'redis-node-1.example.com', port: 6379 },
194
202
  * { host: 'redis-node-2.example.com' }, // Defaults to port 6379
195
203
  * ],
204
+ * databaseId: 5, // Connect to database 5
196
205
  * useTLS: true,
197
206
  * credentials: {
198
207
  * username: 'myUser',
@@ -238,6 +247,33 @@ export interface BaseClientConfiguration {
238
247
  */
239
248
  port?: number;
240
249
  }[];
250
+ /**
251
+ * Index of the logical database to connect to.
252
+ *
253
+ * @remarks
254
+ * - **Standalone Mode**: Works with all Valkey versions.
255
+ * - **Cluster Mode**: Requires Valkey 9.0+ with multi-database cluster mode enabled.
256
+ * - **Reconnection**: Database selection persists across reconnections.
257
+ * - **Default**: If not specified, defaults to database 0.
258
+ * - **Range**: Must be non-negative. The server will validate the upper limit based on its configuration.
259
+ * - **Server Validation**: The server determines the maximum database ID based on its `databases` configuration (standalone) or `cluster-databases` configuration (cluster mode).
260
+ *
261
+ * @example
262
+ * ```typescript
263
+ * // Connect to database 5
264
+ * const config: BaseClientConfiguration = {
265
+ * addresses: [{ host: 'localhost', port: 6379 }],
266
+ * databaseId: 5
267
+ * };
268
+ *
269
+ * // Connect to a higher database ID (server will validate the limit)
270
+ * const configHighDb: BaseClientConfiguration = {
271
+ * addresses: [{ host: 'localhost', port: 6379 }],
272
+ * databaseId: 100
273
+ * };
274
+ * ```
275
+ */
276
+ databaseId?: number;
241
277
  /**
242
278
  * True if communication with the cluster should use Transport Level Security.
243
279
  * Should match the TLS configuration of the server/cluster,
@@ -314,6 +350,7 @@ export interface BaseClientConfiguration {
314
350
  numberOfRetries: number;
315
351
  /**
316
352
  * The multiplier that will be applied to the waiting time between each retry.
353
+ * This value is specified in milliseconds.
317
354
  * Value must be an integer.
318
355
  */
319
356
  factor: number;
@@ -460,6 +497,7 @@ export declare class BaseClient {
460
497
  private dropCommandSpan;
461
498
  processResponse(message: response.Response): void;
462
499
  processPush(response: response.Response): void;
500
+ protected constructor(socket: net.Socket, options?: BaseClientConfiguration);
463
501
  protected getCallbackIndex(): number;
464
502
  private writeBufferedRequestsToSocket;
465
503
  protected ensureClientIsOpen(): void;
@@ -1484,6 +1522,427 @@ export declare class BaseClient {
1484
1522
  * ```
1485
1523
  */
1486
1524
  hrandfieldWithValues(key: GlideString, count: number, options?: DecoderOption): Promise<[GlideString, GlideString][]>;
1525
+ /**
1526
+ * Sets hash fields with expiration times and optional conditional changes.
1527
+ *
1528
+ * @param key - The key of the hash.
1529
+ * @param fieldsAndValues - A map or array of field-value pairs to set.
1530
+ * @param options - Optional parameters including field conditional changes and expiry settings.
1531
+ * See {@link HSetExOptions}.
1532
+ * @returns A number of fields that were set.
1533
+ *
1534
+ * @example
1535
+ * ```typescript
1536
+ * // Set fields with 60 second expiration, only if none exist
1537
+ * const result = await client.hsetex(
1538
+ * "myHash",
1539
+ * { field1: "value1", field2: "value2" },
1540
+ * {
1541
+ * fieldConditionalChange: HashFieldConditionalChange.ONLY_IF_NONE_EXIST,
1542
+ * expiry: { type: TimeUnit.Seconds, count: 60 }
1543
+ * }
1544
+ * );
1545
+ * console.log(result); // 2 - both fields were set with 60s expiration
1546
+ *
1547
+ * // Set fields and keep existing TTL
1548
+ * const keepTtlResult = await client.hsetex(
1549
+ * "myHash",
1550
+ * { field3: "value3" },
1551
+ * { expiry: "KEEPTTL" }
1552
+ * );
1553
+ * console.log(keepTtlResult); // 1 - field was set, existing TTL preserved
1554
+ *
1555
+ * // Set fields with millisecond precision expiration
1556
+ * const msResult = await client.hsetex(
1557
+ * "myHash",
1558
+ * { field4: "value4" },
1559
+ * { expiry: { type: TimeUnit.Milliseconds, count: 5000 } }
1560
+ * );
1561
+ * console.log(msResult); // 1 - field expires in 5000ms
1562
+ *
1563
+ * // Set fields with Unix timestamp expiration
1564
+ * const timestampResult = await client.hsetex(
1565
+ * "myHash",
1566
+ * { field5: "value5" },
1567
+ * { expiry: { type: TimeUnit.UnixSeconds, count: Math.floor(Date.now() / 1000) + 3600 } }
1568
+ * );
1569
+ * console.log(timestampResult); // 1 - field expires in 1 hour
1570
+ *
1571
+ * // Only update existing fields and keep their TTL
1572
+ * const updateResult = await client.hsetex(
1573
+ * "myHash",
1574
+ * { field1: "newValue1" },
1575
+ * {
1576
+ * fieldConditionalChange: HashFieldConditionalChange.ONLY_IF_ALL_EXIST,
1577
+ * expiry: "KEEPTTL"
1578
+ * }
1579
+ * );
1580
+ * console.log(updateResult); // 0 or 1 depending on whether field1 exists
1581
+ * ```
1582
+ *
1583
+ * @since Valkey 9.0.0
1584
+ * @see {@link https://valkey.io/commands/hsetex/|valkey.io}
1585
+ */
1586
+ hsetex(key: GlideString, fieldsAndValues: HashDataType | Record<string, GlideString>, options?: HSetExOptions): Promise<number>;
1587
+ /**
1588
+ * Gets hash fields and optionally sets their expiration.
1589
+ *
1590
+ * @param key - The key of the hash.
1591
+ * @param fields - The fields in the hash stored at `key` to retrieve from the database.
1592
+ * @param options - Optional arguments for the HGETEX command. See {@link HGetExOptions} and see {@link DecoderOption}.
1593
+ * @returns An array of values associated with the given fields,
1594
+ * in the same order as they are requested. For every field that does not exist
1595
+ * in the hash, a null value is returned. If `key` does not exist, returns an
1596
+ * array of null values.
1597
+ *
1598
+ * @example
1599
+ * ```typescript
1600
+ * // Get fields without setting expiration
1601
+ * const values = await client.hgetex("myHash", ["field1", "field2"]);
1602
+ * console.log(values); // ["value1", "value2"] or [null, null] if fields don't exist
1603
+ *
1604
+ * // Get fields and set 30 second expiration
1605
+ * const valuesWithExpiry = await client.hgetex(
1606
+ * "myHash",
1607
+ * ["field1", "field2"],
1608
+ * { expiry: { type: TimeUnit.Seconds, count: 30 } }
1609
+ * );
1610
+ * console.log(valuesWithExpiry); // ["value1", "value2"] - fields now expire in 30s
1611
+ *
1612
+ * // Get fields and remove expiration (make persistent)
1613
+ * const persistValues = await client.hgetex(
1614
+ * "myHash",
1615
+ * ["field1", "field2"],
1616
+ * { expiry: "PERSIST" }
1617
+ * );
1618
+ * console.log(persistValues); // ["value1", "value2"] - fields are now persistent
1619
+ *
1620
+ * // Get fields and set millisecond precision expiration
1621
+ * const msValues = await client.hgetex(
1622
+ * "myHash",
1623
+ * ["field3", "field4"],
1624
+ * { expiry: { type: TimeUnit.Milliseconds, count: 2500 } }
1625
+ * );
1626
+ * console.log(msValues); // ["value3", "value4"] - fields expire in 2500ms
1627
+ *
1628
+ * // Get fields and set Unix timestamp expiration
1629
+ * const timestampValues = await client.hgetex(
1630
+ * "myHash",
1631
+ * ["field5"],
1632
+ * { expiry: { type: TimeUnit.UnixMilliseconds, count: Date.now() + 60000 } }
1633
+ * );
1634
+ * console.log(timestampValues); // ["value5"] - field expires in 1 minute
1635
+ * ```
1636
+ *
1637
+ * @since Valkey 9.0.0
1638
+ * @see {@link https://valkey.io/commands/hgetex/|valkey.io}
1639
+ */
1640
+ hgetex(key: GlideString, fields: GlideString[], options?: HGetExOptions & DecoderOption): Promise<(GlideString | null)[]>;
1641
+ /**
1642
+ * Sets expiration time for hash fields in seconds. Creates the hash if it doesn't exist.
1643
+ *
1644
+ * @see {@link https://valkey.io/commands/hexpire/|valkey.io} for details.
1645
+ *
1646
+ * @param key - The key of the hash.
1647
+ * @param seconds - The expiration time in seconds.
1648
+ * @param fields - The fields to set expiration for.
1649
+ * @param options - Optional parameters for the command.
1650
+ * @returns An array of numbers indicating the result for each field:
1651
+ * - `1` if expiration was set successfully
1652
+ * - `0` if the specified condition (NX, XX, GT, LT) was not met
1653
+ * - `-2` if the field does not exist or the key does not exist
1654
+ * - `2` when called with 0 seconds (field deleted)
1655
+ *
1656
+ * @example
1657
+ * ```typescript
1658
+ * // Set expiration for hash fields
1659
+ * const result = await client.hexpire("my_hash", 60, ["field1", "field2"]);
1660
+ * console.log(result); // [1, 1] - expiration set for both fields
1661
+ * ```
1662
+ *
1663
+ * @example
1664
+ * ```typescript
1665
+ * // Set expiration only if fields don't have expiration
1666
+ * const result = await client.hexpire("my_hash", 120, ["field1", "field2"], {
1667
+ * condition: HashExpirationCondition.ONLY_IF_NO_EXPIRY
1668
+ * });
1669
+ * console.log(result); // [1, 0] - expiration set for field1, condition not met for field2
1670
+ * ```
1671
+ *
1672
+ * @example
1673
+ * ```typescript
1674
+ * // Set expiration with greater than condition
1675
+ * const result = await client.hexpire("my_hash", 300, ["field1"], {
1676
+ * condition: HashExpirationCondition.ONLY_IF_GREATER_THAN_CURRENT
1677
+ * });
1678
+ * console.log(result); // [1] - expiration set because 300 > current TTL
1679
+ * ```
1680
+ */
1681
+ hexpire(key: GlideString, seconds: number, fields: GlideString[], options?: HExpireOptions): Promise<number[]>;
1682
+ /**
1683
+ * Removes the expiration time associated with each specified field, causing them to persist.
1684
+ *
1685
+ * @see {@link https://valkey.io/commands/hpersist/|valkey.io} for details.
1686
+ *
1687
+ * @param key - The key of the hash.
1688
+ * @param fields - The fields in the hash to remove expiration from.
1689
+ * @returns An array of numbers indicating the result for each field:
1690
+ * - `1` if the field's expiration was removed successfully.
1691
+ * - `-1` if the field exists but has no associated expiration.
1692
+ * - `-2` if the field does not exist or the key does not exist.
1693
+ *
1694
+ * @example
1695
+ * ```typescript
1696
+ * // Remove expiration from hash fields
1697
+ * const result = await client.hpersist("my_hash", ["field1", "field2"]);
1698
+ * console.log(result); // [1, -1] - expiration removed from field1, field2 had no expiration
1699
+ * ```
1700
+ *
1701
+ * @example
1702
+ * ```typescript
1703
+ * // Remove expiration from a single field
1704
+ * const result = await client.hpersist("my_hash", ["field1"]);
1705
+ * console.log(result); // [1] - expiration removed from field1
1706
+ * ```
1707
+ */
1708
+ hpersist(key: GlideString, fields: GlideString[]): Promise<number[]>;
1709
+ /**
1710
+ * Sets expiration time for hash fields in milliseconds. Creates the hash if it doesn't exist.
1711
+ *
1712
+ * @see {@link https://valkey.io/commands/hpexpire/|valkey.io} for details.
1713
+ *
1714
+ * @param key - The key of the hash.
1715
+ * @param milliseconds - The expiration time in milliseconds.
1716
+ * @param fields - The fields to set expiration for.
1717
+ * @param options - Optional arguments for the HPEXPIRE command. See {@link HPExpireOptions}.
1718
+ * @returns An array of numbers indicating the result for each field:
1719
+ * - `1` if expiration was set successfully
1720
+ * - `0` if the specified condition (NX, XX, GT, LT) was not met
1721
+ * - `-2` if the field does not exist or the key does not exist
1722
+ * - `2` when called with 0 milliseconds (field deleted)
1723
+ *
1724
+ * @example
1725
+ * ```typescript
1726
+ * // Set expiration for hash fields in milliseconds
1727
+ * const result = await client.hpexpire("my_hash", 60000, ["field1", "field2"]);
1728
+ * console.log(result); // [1, 1] - expiration set for both fields
1729
+ * ```
1730
+ *
1731
+ * @example
1732
+ * ```typescript
1733
+ * // Set expiration only if fields don't have expiration
1734
+ * const result = await client.hpexpire("my_hash", 120000, ["field1", "field2"], {
1735
+ * condition: HashExpirationCondition.ONLY_IF_NO_EXPIRY
1736
+ * });
1737
+ * console.log(result); // [1, 0] - expiration set for field1, condition not met for field2
1738
+ * ```
1739
+ *
1740
+ * @example
1741
+ * ```typescript
1742
+ * // Set expiration with greater than condition
1743
+ * const result = await client.hpexpire("my_hash", 300000, ["field1"], {
1744
+ * condition: HashExpirationCondition.ONLY_IF_GREATER_THAN_CURRENT
1745
+ * });
1746
+ * console.log(result); // [1] - expiration set because 300000 ms > current TTL
1747
+ * ```
1748
+ */
1749
+ hpexpire(key: GlideString, milliseconds: number, fields: GlideString[], options?: HExpireOptions): Promise<number[]>;
1750
+ /**
1751
+ * Sets expiration time for hash fields using an absolute Unix timestamp in seconds. Creates the hash if it doesn't exist.
1752
+ *
1753
+ * @see {@link https://valkey.io/commands/hexpireat/|valkey.io} for details.
1754
+ *
1755
+ * @param key - The key of the hash.
1756
+ * @param unixTimestampSeconds - The expiration time as a Unix timestamp in seconds.
1757
+ * @param fields - The fields to set expiration for.
1758
+ * @param options - Optional arguments for the HEXPIREAT command. See {@link HExpireOptions}.
1759
+ * @returns An array of numbers indicating the result for each field:
1760
+ * - `1` if expiration was set successfully
1761
+ * - `0` if the specified condition (NX, XX, GT, LT) was not met
1762
+ * - `-2` if the field does not exist or the key does not exist
1763
+ * - `2` when called with 0 seconds (field deleted)
1764
+ *
1765
+ * @example
1766
+ * ```typescript
1767
+ * // Set expiration for hash fields using Unix timestamp
1768
+ * const futureTimestamp = Math.floor(Date.now() / 1000) + 3600; // 1 hour from now
1769
+ * const result = await client.hexpireat("my_hash", futureTimestamp, ["field1", "field2"]);
1770
+ * console.log(result); // [1, 1] - expiration set for both fields
1771
+ * ```
1772
+ *
1773
+ * @example
1774
+ * ```typescript
1775
+ * // Set expiration only if fields don't have expiration
1776
+ * const futureTimestamp = Math.floor(Date.now() / 1000) + 7200; // 2 hours from now
1777
+ * const result = await client.hexpireat("my_hash", futureTimestamp, ["field1", "field2"], {
1778
+ * condition: HashExpirationCondition.ONLY_IF_NO_EXPIRY
1779
+ * });
1780
+ * console.log(result); // [1, 0] - expiration set for field1, condition not met for field2
1781
+ * ```
1782
+ *
1783
+ * @example
1784
+ * ```typescript
1785
+ * // Set expiration with greater than condition
1786
+ * const futureTimestamp = Math.floor(Date.now() / 1000) + 10800; // 3 hours from now
1787
+ * const result = await client.hexpireat("my_hash", futureTimestamp, ["field1"], {
1788
+ * condition: HashExpirationCondition.ONLY_IF_GREATER_THAN_CURRENT
1789
+ * });
1790
+ * console.log(result); // [1] - expiration set because timestamp > current expiration
1791
+ * ```
1792
+ */
1793
+ hexpireat(key: GlideString, unixTimestampSeconds: number, fields: GlideString[], options?: HExpireOptions): Promise<number[]>;
1794
+ /**
1795
+ * Sets expiration time for hash fields using an absolute Unix timestamp in milliseconds. Creates the hash if it doesn't exist.
1796
+ *
1797
+ * @see {@link https://valkey.io/commands/hpexpireat/|valkey.io} for details.
1798
+ *
1799
+ * @param key - The key of the hash.
1800
+ * @param unixTimestampMilliseconds - The expiration time as a Unix timestamp in milliseconds.
1801
+ * @param fields - The fields to set expiration for.
1802
+ * @param options - Optional arguments for the HPEXPIREAT command. See {@link HExpireOptions}.
1803
+ * @returns An array of numbers indicating the result for each field:
1804
+ * - `1` if expiration was set successfully
1805
+ * - `0` if the specified condition (NX, XX, GT, LT) was not met
1806
+ * - `-2` if the field does not exist or the key does not exist
1807
+ * - `2` when called with 0 milliseconds (field deleted)
1808
+ *
1809
+ * @example
1810
+ * ```typescript
1811
+ * // Set expiration for hash fields using Unix timestamp in milliseconds
1812
+ * const futureTimestamp = Date.now() + 3600000; // 1 hour from now
1813
+ * const result = await client.hpexpireat("my_hash", futureTimestamp, ["field1", "field2"]);
1814
+ * console.log(result); // [1, 1] - expiration set for both fields
1815
+ * ```
1816
+ *
1817
+ * @example
1818
+ * ```typescript
1819
+ * // Set expiration only if fields don't have expiration
1820
+ * const futureTimestamp = Date.now() + 7200000; // 2 hours from now
1821
+ * const result = await client.hpexpireat("my_hash", futureTimestamp, ["field1", "field2"], {
1822
+ * condition: HashExpirationCondition.ONLY_IF_NO_EXPIRY
1823
+ * });
1824
+ * console.log(result); // [1, 0] - expiration set for field1, condition not met for field2
1825
+ * ```
1826
+ *
1827
+ * @example
1828
+ * ```typescript
1829
+ * // Set expiration with greater than condition
1830
+ * const futureTimestamp = Date.now() + 10800000; // 3 hours from now
1831
+ * const result = await client.hpexpireat("my_hash", futureTimestamp, ["field1"], {
1832
+ * condition: HashExpirationCondition.ONLY_IF_GREATER_THAN_CURRENT
1833
+ * });
1834
+ * console.log(result); // [1] - expiration set because timestamp > current expiration
1835
+ * ```
1836
+ */
1837
+ hpexpireat(key: GlideString, unixTimestampMilliseconds: number, fields: GlideString[], options?: HExpireOptions): Promise<number[]>;
1838
+ /**
1839
+ * Returns the remaining time to live of hash fields that have a timeout, in seconds.
1840
+ *
1841
+ * @see {@link https://valkey.io/commands/httl/|valkey.io} for details.
1842
+ *
1843
+ * @param key - The key of the hash.
1844
+ * @param fields - The fields in the hash stored at `key` to retrieve the TTL for.
1845
+ * @returns An array of TTL values in seconds for the specified fields.
1846
+ * - For fields with a timeout, returns the remaining time in seconds.
1847
+ * - For fields that exist but have no associated expire, returns -1.
1848
+ * - For fields that do not exist, returns -2.
1849
+ *
1850
+ * @example
1851
+ * ```typescript
1852
+ * // Get TTL for hash fields
1853
+ * const result = await client.httl("my_hash", ["field1", "field2", "field3"]);
1854
+ * console.log(result); // [120, -1, -2] - field1 expires in 120 seconds, field2 has no expiration, field3 doesn't exist
1855
+ * ```
1856
+ *
1857
+ * @example
1858
+ * ```typescript
1859
+ * // Get TTL for a single field
1860
+ * const result = await client.httl("my_hash", ["field1"]);
1861
+ * console.log(result); // [60] - field1 expires in 60 seconds
1862
+ * ```
1863
+ */
1864
+ httl(key: GlideString, fields: GlideString[]): Promise<number[]>;
1865
+ /**
1866
+ * Returns the absolute Unix timestamp (in seconds) at which hash fields will expire.
1867
+ *
1868
+ * @see {@link https://valkey.io/commands/hexpiretime/|valkey.io} for details.
1869
+ *
1870
+ * @param key - The key of the hash.
1871
+ * @param fields - The list of fields to get the expiration timestamp for.
1872
+ * @returns An array of expiration timestamps in seconds for the specified fields:
1873
+ * - For fields with a timeout, returns the absolute Unix timestamp in seconds.
1874
+ * - For fields without a timeout, returns -1.
1875
+ * - For fields that do not exist, returns -2.
1876
+ *
1877
+ * @example
1878
+ * ```typescript
1879
+ * // Get expiration timestamps for hash fields
1880
+ * const result = await client.hexpiretime("my_hash", ["field1", "field2", "field3"]);
1881
+ * console.log(result); // [1672531200, -1, -2] - field1 expires at timestamp 1672531200, field2 has no expiration, field3 doesn't exist
1882
+ * ```
1883
+ *
1884
+ * @example
1885
+ * ```typescript
1886
+ * // Get expiration timestamp for a single field
1887
+ * const result = await client.hexpiretime("my_hash", ["field1"]);
1888
+ * console.log(result); // [1672531200] - field1 expires at timestamp 1672531200
1889
+ * ```
1890
+ */
1891
+ hexpiretime(key: GlideString, fields: GlideString[]): Promise<number[]>;
1892
+ /**
1893
+ * Returns the absolute Unix timestamp (in milliseconds) at which hash fields will expire.
1894
+ *
1895
+ * @see {@link https://valkey.io/commands/hpexpiretime/|valkey.io} for details.
1896
+ *
1897
+ * @param key - The key of the hash.
1898
+ * @param fields - The list of fields to get the expiration timestamp for.
1899
+ * @returns An array of expiration timestamps in milliseconds for the specified fields:
1900
+ * - For fields with a timeout, returns the absolute Unix timestamp in milliseconds.
1901
+ * - For fields without a timeout, returns -1.
1902
+ * - For fields that do not exist, returns -2.
1903
+ *
1904
+ * @example
1905
+ * ```typescript
1906
+ * // Get expiration timestamps for hash fields in milliseconds
1907
+ * const result = await client.hpexpiretime("my_hash", ["field1", "field2", "field3"]);
1908
+ * console.log(result); // [1672531200000, -1, -2] - field1 expires at timestamp 1672531200000, field2 has no expiration, field3 doesn't exist
1909
+ * ```
1910
+ *
1911
+ * @example
1912
+ * ```typescript
1913
+ * // Get expiration timestamp for a single field in milliseconds
1914
+ * const result = await client.hpexpiretime("my_hash", ["field1"]);
1915
+ * console.log(result); // [1672531200000] - field1 expires at timestamp 1672531200000
1916
+ * ```
1917
+ */
1918
+ hpexpiretime(key: GlideString, fields: GlideString[]): Promise<number[]>;
1919
+ /**
1920
+ * Returns the remaining time to live of hash fields that have a timeout, in milliseconds.
1921
+ *
1922
+ * @see {@link https://valkey.io/commands/hpttl/|valkey.io} for details.
1923
+ *
1924
+ * @param key - The key of the hash.
1925
+ * @param fields - The list of fields to get the TTL for.
1926
+ * @returns An array of TTL values in milliseconds for the specified fields:
1927
+ * - For fields with a timeout, returns the remaining TTL in milliseconds.
1928
+ * - For fields without a timeout, returns -1.
1929
+ * - For fields that do not exist, returns -2.
1930
+ *
1931
+ * @example
1932
+ * ```typescript
1933
+ * // Get TTL for hash fields in milliseconds
1934
+ * const result = await client.hpttl("my_hash", ["field1", "field2", "field3"]);
1935
+ * console.log(result); // [120000, -1, -2] - field1 expires in 120000 ms, field2 has no expiration, field3 doesn't exist
1936
+ * ```
1937
+ *
1938
+ * @example
1939
+ * ```typescript
1940
+ * // Get TTL for a single field in milliseconds
1941
+ * const result = await client.hpttl("my_hash", ["field1"]);
1942
+ * console.log(result); // [60000] - field1 expires in 60000 ms
1943
+ * ```
1944
+ */
1945
+ hpttl(key: GlideString, fields: GlideString[]): Promise<number[]>;
1487
1946
  /** Inserts all the specified values at the head of the list stored at `key`.
1488
1947
  * `elements` are inserted one after the other to the head of the list, from the leftmost element to the rightmost element.
1489
1948
  * If `key` does not exist, it is created as empty list before performing the push operations.