@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.
- package/build-ts/BaseClient.d.ts +461 -2
- package/build-ts/BaseClient.js +450 -3
- package/build-ts/Batch.d.ts +215 -1
- package/build-ts/Batch.js +236 -0
- package/build-ts/Commands.d.ts +167 -0
- package/build-ts/Commands.js +223 -1
- package/build-ts/GlideClient.d.ts +21 -11
- package/build-ts/GlideClient.js +18 -5
- package/build-ts/GlideClusterClient.d.ts +15 -8
- package/build-ts/GlideClusterClient.js +10 -8
- package/build-ts/ProtobufMessage.d.ts +11 -0
- package/build-ts/ProtobufMessage.js +22 -0
- package/build-ts/native.d.ts +61 -82
- package/build-ts/native.js +296 -336
- package/package.json +9 -8
package/build-ts/BaseClient.js
CHANGED
|
@@ -403,9 +403,6 @@ class BaseClient {
|
|
|
403
403
|
this.completePubSubFuturesSafe();
|
|
404
404
|
}
|
|
405
405
|
}
|
|
406
|
-
/**
|
|
407
|
-
* @internal
|
|
408
|
-
*/
|
|
409
406
|
constructor(socket, options) {
|
|
410
407
|
// if logger has been initialized by the external-user on info level this log will be shown
|
|
411
408
|
_1.Logger.log("info", "Client lifetime", `construct client`);
|
|
@@ -1794,6 +1791,449 @@ class BaseClient {
|
|
|
1794
1791
|
async hrandfieldWithValues(key, count, options) {
|
|
1795
1792
|
return this.createWritePromise((0, _1.createHRandField)(key, count, true), options);
|
|
1796
1793
|
}
|
|
1794
|
+
/**
|
|
1795
|
+
* Sets hash fields with expiration times and optional conditional changes.
|
|
1796
|
+
*
|
|
1797
|
+
* @param key - The key of the hash.
|
|
1798
|
+
* @param fieldsAndValues - A map or array of field-value pairs to set.
|
|
1799
|
+
* @param options - Optional parameters including field conditional changes and expiry settings.
|
|
1800
|
+
* See {@link HSetExOptions}.
|
|
1801
|
+
* @returns A number of fields that were set.
|
|
1802
|
+
*
|
|
1803
|
+
* @example
|
|
1804
|
+
* ```typescript
|
|
1805
|
+
* // Set fields with 60 second expiration, only if none exist
|
|
1806
|
+
* const result = await client.hsetex(
|
|
1807
|
+
* "myHash",
|
|
1808
|
+
* { field1: "value1", field2: "value2" },
|
|
1809
|
+
* {
|
|
1810
|
+
* fieldConditionalChange: HashFieldConditionalChange.ONLY_IF_NONE_EXIST,
|
|
1811
|
+
* expiry: { type: TimeUnit.Seconds, count: 60 }
|
|
1812
|
+
* }
|
|
1813
|
+
* );
|
|
1814
|
+
* console.log(result); // 2 - both fields were set with 60s expiration
|
|
1815
|
+
*
|
|
1816
|
+
* // Set fields and keep existing TTL
|
|
1817
|
+
* const keepTtlResult = await client.hsetex(
|
|
1818
|
+
* "myHash",
|
|
1819
|
+
* { field3: "value3" },
|
|
1820
|
+
* { expiry: "KEEPTTL" }
|
|
1821
|
+
* );
|
|
1822
|
+
* console.log(keepTtlResult); // 1 - field was set, existing TTL preserved
|
|
1823
|
+
*
|
|
1824
|
+
* // Set fields with millisecond precision expiration
|
|
1825
|
+
* const msResult = await client.hsetex(
|
|
1826
|
+
* "myHash",
|
|
1827
|
+
* { field4: "value4" },
|
|
1828
|
+
* { expiry: { type: TimeUnit.Milliseconds, count: 5000 } }
|
|
1829
|
+
* );
|
|
1830
|
+
* console.log(msResult); // 1 - field expires in 5000ms
|
|
1831
|
+
*
|
|
1832
|
+
* // Set fields with Unix timestamp expiration
|
|
1833
|
+
* const timestampResult = await client.hsetex(
|
|
1834
|
+
* "myHash",
|
|
1835
|
+
* { field5: "value5" },
|
|
1836
|
+
* { expiry: { type: TimeUnit.UnixSeconds, count: Math.floor(Date.now() / 1000) + 3600 } }
|
|
1837
|
+
* );
|
|
1838
|
+
* console.log(timestampResult); // 1 - field expires in 1 hour
|
|
1839
|
+
*
|
|
1840
|
+
* // Only update existing fields and keep their TTL
|
|
1841
|
+
* const updateResult = await client.hsetex(
|
|
1842
|
+
* "myHash",
|
|
1843
|
+
* { field1: "newValue1" },
|
|
1844
|
+
* {
|
|
1845
|
+
* fieldConditionalChange: HashFieldConditionalChange.ONLY_IF_ALL_EXIST,
|
|
1846
|
+
* expiry: "KEEPTTL"
|
|
1847
|
+
* }
|
|
1848
|
+
* );
|
|
1849
|
+
* console.log(updateResult); // 0 or 1 depending on whether field1 exists
|
|
1850
|
+
* ```
|
|
1851
|
+
*
|
|
1852
|
+
* @since Valkey 9.0.0
|
|
1853
|
+
* @see {@link https://valkey.io/commands/hsetex/|valkey.io}
|
|
1854
|
+
*/
|
|
1855
|
+
async hsetex(key, fieldsAndValues, options) {
|
|
1856
|
+
return this.createWritePromise((0, _1.createHSetEx)(key, (0, _1.convertFieldsAndValuesToHashDataType)(fieldsAndValues), options));
|
|
1857
|
+
}
|
|
1858
|
+
/**
|
|
1859
|
+
* Gets hash fields and optionally sets their expiration.
|
|
1860
|
+
*
|
|
1861
|
+
* @param key - The key of the hash.
|
|
1862
|
+
* @param fields - The fields in the hash stored at `key` to retrieve from the database.
|
|
1863
|
+
* @param options - Optional arguments for the HGETEX command. See {@link HGetExOptions} and see {@link DecoderOption}.
|
|
1864
|
+
* @returns An array of values associated with the given fields,
|
|
1865
|
+
* in the same order as they are requested. For every field that does not exist
|
|
1866
|
+
* in the hash, a null value is returned. If `key` does not exist, returns an
|
|
1867
|
+
* array of null values.
|
|
1868
|
+
*
|
|
1869
|
+
* @example
|
|
1870
|
+
* ```typescript
|
|
1871
|
+
* // Get fields without setting expiration
|
|
1872
|
+
* const values = await client.hgetex("myHash", ["field1", "field2"]);
|
|
1873
|
+
* console.log(values); // ["value1", "value2"] or [null, null] if fields don't exist
|
|
1874
|
+
*
|
|
1875
|
+
* // Get fields and set 30 second expiration
|
|
1876
|
+
* const valuesWithExpiry = await client.hgetex(
|
|
1877
|
+
* "myHash",
|
|
1878
|
+
* ["field1", "field2"],
|
|
1879
|
+
* { expiry: { type: TimeUnit.Seconds, count: 30 } }
|
|
1880
|
+
* );
|
|
1881
|
+
* console.log(valuesWithExpiry); // ["value1", "value2"] - fields now expire in 30s
|
|
1882
|
+
*
|
|
1883
|
+
* // Get fields and remove expiration (make persistent)
|
|
1884
|
+
* const persistValues = await client.hgetex(
|
|
1885
|
+
* "myHash",
|
|
1886
|
+
* ["field1", "field2"],
|
|
1887
|
+
* { expiry: "PERSIST" }
|
|
1888
|
+
* );
|
|
1889
|
+
* console.log(persistValues); // ["value1", "value2"] - fields are now persistent
|
|
1890
|
+
*
|
|
1891
|
+
* // Get fields and set millisecond precision expiration
|
|
1892
|
+
* const msValues = await client.hgetex(
|
|
1893
|
+
* "myHash",
|
|
1894
|
+
* ["field3", "field4"],
|
|
1895
|
+
* { expiry: { type: TimeUnit.Milliseconds, count: 2500 } }
|
|
1896
|
+
* );
|
|
1897
|
+
* console.log(msValues); // ["value3", "value4"] - fields expire in 2500ms
|
|
1898
|
+
*
|
|
1899
|
+
* // Get fields and set Unix timestamp expiration
|
|
1900
|
+
* const timestampValues = await client.hgetex(
|
|
1901
|
+
* "myHash",
|
|
1902
|
+
* ["field5"],
|
|
1903
|
+
* { expiry: { type: TimeUnit.UnixMilliseconds, count: Date.now() + 60000 } }
|
|
1904
|
+
* );
|
|
1905
|
+
* console.log(timestampValues); // ["value5"] - field expires in 1 minute
|
|
1906
|
+
* ```
|
|
1907
|
+
*
|
|
1908
|
+
* @since Valkey 9.0.0
|
|
1909
|
+
* @see {@link https://valkey.io/commands/hgetex/|valkey.io}
|
|
1910
|
+
*/
|
|
1911
|
+
async hgetex(key, fields, options) {
|
|
1912
|
+
return this.createWritePromise((0, _1.createHGetEx)(key, fields, options), options);
|
|
1913
|
+
}
|
|
1914
|
+
/**
|
|
1915
|
+
* Sets expiration time for hash fields in seconds. Creates the hash if it doesn't exist.
|
|
1916
|
+
*
|
|
1917
|
+
* @see {@link https://valkey.io/commands/hexpire/|valkey.io} for details.
|
|
1918
|
+
*
|
|
1919
|
+
* @param key - The key of the hash.
|
|
1920
|
+
* @param seconds - The expiration time in seconds.
|
|
1921
|
+
* @param fields - The fields to set expiration for.
|
|
1922
|
+
* @param options - Optional parameters for the command.
|
|
1923
|
+
* @returns An array of numbers indicating the result for each field:
|
|
1924
|
+
* - `1` if expiration was set successfully
|
|
1925
|
+
* - `0` if the specified condition (NX, XX, GT, LT) was not met
|
|
1926
|
+
* - `-2` if the field does not exist or the key does not exist
|
|
1927
|
+
* - `2` when called with 0 seconds (field deleted)
|
|
1928
|
+
*
|
|
1929
|
+
* @example
|
|
1930
|
+
* ```typescript
|
|
1931
|
+
* // Set expiration for hash fields
|
|
1932
|
+
* const result = await client.hexpire("my_hash", 60, ["field1", "field2"]);
|
|
1933
|
+
* console.log(result); // [1, 1] - expiration set for both fields
|
|
1934
|
+
* ```
|
|
1935
|
+
*
|
|
1936
|
+
* @example
|
|
1937
|
+
* ```typescript
|
|
1938
|
+
* // Set expiration only if fields don't have expiration
|
|
1939
|
+
* const result = await client.hexpire("my_hash", 120, ["field1", "field2"], {
|
|
1940
|
+
* condition: HashExpirationCondition.ONLY_IF_NO_EXPIRY
|
|
1941
|
+
* });
|
|
1942
|
+
* console.log(result); // [1, 0] - expiration set for field1, condition not met for field2
|
|
1943
|
+
* ```
|
|
1944
|
+
*
|
|
1945
|
+
* @example
|
|
1946
|
+
* ```typescript
|
|
1947
|
+
* // Set expiration with greater than condition
|
|
1948
|
+
* const result = await client.hexpire("my_hash", 300, ["field1"], {
|
|
1949
|
+
* condition: HashExpirationCondition.ONLY_IF_GREATER_THAN_CURRENT
|
|
1950
|
+
* });
|
|
1951
|
+
* console.log(result); // [1] - expiration set because 300 > current TTL
|
|
1952
|
+
* ```
|
|
1953
|
+
*/
|
|
1954
|
+
async hexpire(key, seconds, fields, options) {
|
|
1955
|
+
return this.createWritePromise((0, _1.createHExpire)(key, seconds, fields, options));
|
|
1956
|
+
}
|
|
1957
|
+
/**
|
|
1958
|
+
* Removes the expiration time associated with each specified field, causing them to persist.
|
|
1959
|
+
*
|
|
1960
|
+
* @see {@link https://valkey.io/commands/hpersist/|valkey.io} for details.
|
|
1961
|
+
*
|
|
1962
|
+
* @param key - The key of the hash.
|
|
1963
|
+
* @param fields - The fields in the hash to remove expiration from.
|
|
1964
|
+
* @returns An array of numbers indicating the result for each field:
|
|
1965
|
+
* - `1` if the field's expiration was removed successfully.
|
|
1966
|
+
* - `-1` if the field exists but has no associated expiration.
|
|
1967
|
+
* - `-2` if the field does not exist or the key does not exist.
|
|
1968
|
+
*
|
|
1969
|
+
* @example
|
|
1970
|
+
* ```typescript
|
|
1971
|
+
* // Remove expiration from hash fields
|
|
1972
|
+
* const result = await client.hpersist("my_hash", ["field1", "field2"]);
|
|
1973
|
+
* console.log(result); // [1, -1] - expiration removed from field1, field2 had no expiration
|
|
1974
|
+
* ```
|
|
1975
|
+
*
|
|
1976
|
+
* @example
|
|
1977
|
+
* ```typescript
|
|
1978
|
+
* // Remove expiration from a single field
|
|
1979
|
+
* const result = await client.hpersist("my_hash", ["field1"]);
|
|
1980
|
+
* console.log(result); // [1] - expiration removed from field1
|
|
1981
|
+
* ```
|
|
1982
|
+
*/
|
|
1983
|
+
async hpersist(key, fields) {
|
|
1984
|
+
return this.createWritePromise((0, _1.createHPersist)(key, fields));
|
|
1985
|
+
}
|
|
1986
|
+
/**
|
|
1987
|
+
* Sets expiration time for hash fields in milliseconds. Creates the hash if it doesn't exist.
|
|
1988
|
+
*
|
|
1989
|
+
* @see {@link https://valkey.io/commands/hpexpire/|valkey.io} for details.
|
|
1990
|
+
*
|
|
1991
|
+
* @param key - The key of the hash.
|
|
1992
|
+
* @param milliseconds - The expiration time in milliseconds.
|
|
1993
|
+
* @param fields - The fields to set expiration for.
|
|
1994
|
+
* @param options - Optional arguments for the HPEXPIRE command. See {@link HPExpireOptions}.
|
|
1995
|
+
* @returns An array of numbers indicating the result for each field:
|
|
1996
|
+
* - `1` if expiration was set successfully
|
|
1997
|
+
* - `0` if the specified condition (NX, XX, GT, LT) was not met
|
|
1998
|
+
* - `-2` if the field does not exist or the key does not exist
|
|
1999
|
+
* - `2` when called with 0 milliseconds (field deleted)
|
|
2000
|
+
*
|
|
2001
|
+
* @example
|
|
2002
|
+
* ```typescript
|
|
2003
|
+
* // Set expiration for hash fields in milliseconds
|
|
2004
|
+
* const result = await client.hpexpire("my_hash", 60000, ["field1", "field2"]);
|
|
2005
|
+
* console.log(result); // [1, 1] - expiration set for both fields
|
|
2006
|
+
* ```
|
|
2007
|
+
*
|
|
2008
|
+
* @example
|
|
2009
|
+
* ```typescript
|
|
2010
|
+
* // Set expiration only if fields don't have expiration
|
|
2011
|
+
* const result = await client.hpexpire("my_hash", 120000, ["field1", "field2"], {
|
|
2012
|
+
* condition: HashExpirationCondition.ONLY_IF_NO_EXPIRY
|
|
2013
|
+
* });
|
|
2014
|
+
* console.log(result); // [1, 0] - expiration set for field1, condition not met for field2
|
|
2015
|
+
* ```
|
|
2016
|
+
*
|
|
2017
|
+
* @example
|
|
2018
|
+
* ```typescript
|
|
2019
|
+
* // Set expiration with greater than condition
|
|
2020
|
+
* const result = await client.hpexpire("my_hash", 300000, ["field1"], {
|
|
2021
|
+
* condition: HashExpirationCondition.ONLY_IF_GREATER_THAN_CURRENT
|
|
2022
|
+
* });
|
|
2023
|
+
* console.log(result); // [1] - expiration set because 300000 ms > current TTL
|
|
2024
|
+
* ```
|
|
2025
|
+
*/
|
|
2026
|
+
async hpexpire(key, milliseconds, fields, options) {
|
|
2027
|
+
return this.createWritePromise((0, _1.createHPExpire)(key, milliseconds, fields, options));
|
|
2028
|
+
}
|
|
2029
|
+
/**
|
|
2030
|
+
* Sets expiration time for hash fields using an absolute Unix timestamp in seconds. Creates the hash if it doesn't exist.
|
|
2031
|
+
*
|
|
2032
|
+
* @see {@link https://valkey.io/commands/hexpireat/|valkey.io} for details.
|
|
2033
|
+
*
|
|
2034
|
+
* @param key - The key of the hash.
|
|
2035
|
+
* @param unixTimestampSeconds - The expiration time as a Unix timestamp in seconds.
|
|
2036
|
+
* @param fields - The fields to set expiration for.
|
|
2037
|
+
* @param options - Optional arguments for the HEXPIREAT command. See {@link HExpireOptions}.
|
|
2038
|
+
* @returns An array of numbers indicating the result for each field:
|
|
2039
|
+
* - `1` if expiration was set successfully
|
|
2040
|
+
* - `0` if the specified condition (NX, XX, GT, LT) was not met
|
|
2041
|
+
* - `-2` if the field does not exist or the key does not exist
|
|
2042
|
+
* - `2` when called with 0 seconds (field deleted)
|
|
2043
|
+
*
|
|
2044
|
+
* @example
|
|
2045
|
+
* ```typescript
|
|
2046
|
+
* // Set expiration for hash fields using Unix timestamp
|
|
2047
|
+
* const futureTimestamp = Math.floor(Date.now() / 1000) + 3600; // 1 hour from now
|
|
2048
|
+
* const result = await client.hexpireat("my_hash", futureTimestamp, ["field1", "field2"]);
|
|
2049
|
+
* console.log(result); // [1, 1] - expiration set for both fields
|
|
2050
|
+
* ```
|
|
2051
|
+
*
|
|
2052
|
+
* @example
|
|
2053
|
+
* ```typescript
|
|
2054
|
+
* // Set expiration only if fields don't have expiration
|
|
2055
|
+
* const futureTimestamp = Math.floor(Date.now() / 1000) + 7200; // 2 hours from now
|
|
2056
|
+
* const result = await client.hexpireat("my_hash", futureTimestamp, ["field1", "field2"], {
|
|
2057
|
+
* condition: HashExpirationCondition.ONLY_IF_NO_EXPIRY
|
|
2058
|
+
* });
|
|
2059
|
+
* console.log(result); // [1, 0] - expiration set for field1, condition not met for field2
|
|
2060
|
+
* ```
|
|
2061
|
+
*
|
|
2062
|
+
* @example
|
|
2063
|
+
* ```typescript
|
|
2064
|
+
* // Set expiration with greater than condition
|
|
2065
|
+
* const futureTimestamp = Math.floor(Date.now() / 1000) + 10800; // 3 hours from now
|
|
2066
|
+
* const result = await client.hexpireat("my_hash", futureTimestamp, ["field1"], {
|
|
2067
|
+
* condition: HashExpirationCondition.ONLY_IF_GREATER_THAN_CURRENT
|
|
2068
|
+
* });
|
|
2069
|
+
* console.log(result); // [1] - expiration set because timestamp > current expiration
|
|
2070
|
+
* ```
|
|
2071
|
+
*/
|
|
2072
|
+
async hexpireat(key, unixTimestampSeconds, fields, options) {
|
|
2073
|
+
return this.createWritePromise((0, _1.createHExpireAt)(key, unixTimestampSeconds, fields, options));
|
|
2074
|
+
}
|
|
2075
|
+
/**
|
|
2076
|
+
* Sets expiration time for hash fields using an absolute Unix timestamp in milliseconds. Creates the hash if it doesn't exist.
|
|
2077
|
+
*
|
|
2078
|
+
* @see {@link https://valkey.io/commands/hpexpireat/|valkey.io} for details.
|
|
2079
|
+
*
|
|
2080
|
+
* @param key - The key of the hash.
|
|
2081
|
+
* @param unixTimestampMilliseconds - The expiration time as a Unix timestamp in milliseconds.
|
|
2082
|
+
* @param fields - The fields to set expiration for.
|
|
2083
|
+
* @param options - Optional arguments for the HPEXPIREAT command. See {@link HExpireOptions}.
|
|
2084
|
+
* @returns An array of numbers indicating the result for each field:
|
|
2085
|
+
* - `1` if expiration was set successfully
|
|
2086
|
+
* - `0` if the specified condition (NX, XX, GT, LT) was not met
|
|
2087
|
+
* - `-2` if the field does not exist or the key does not exist
|
|
2088
|
+
* - `2` when called with 0 milliseconds (field deleted)
|
|
2089
|
+
*
|
|
2090
|
+
* @example
|
|
2091
|
+
* ```typescript
|
|
2092
|
+
* // Set expiration for hash fields using Unix timestamp in milliseconds
|
|
2093
|
+
* const futureTimestamp = Date.now() + 3600000; // 1 hour from now
|
|
2094
|
+
* const result = await client.hpexpireat("my_hash", futureTimestamp, ["field1", "field2"]);
|
|
2095
|
+
* console.log(result); // [1, 1] - expiration set for both fields
|
|
2096
|
+
* ```
|
|
2097
|
+
*
|
|
2098
|
+
* @example
|
|
2099
|
+
* ```typescript
|
|
2100
|
+
* // Set expiration only if fields don't have expiration
|
|
2101
|
+
* const futureTimestamp = Date.now() + 7200000; // 2 hours from now
|
|
2102
|
+
* const result = await client.hpexpireat("my_hash", futureTimestamp, ["field1", "field2"], {
|
|
2103
|
+
* condition: HashExpirationCondition.ONLY_IF_NO_EXPIRY
|
|
2104
|
+
* });
|
|
2105
|
+
* console.log(result); // [1, 0] - expiration set for field1, condition not met for field2
|
|
2106
|
+
* ```
|
|
2107
|
+
*
|
|
2108
|
+
* @example
|
|
2109
|
+
* ```typescript
|
|
2110
|
+
* // Set expiration with greater than condition
|
|
2111
|
+
* const futureTimestamp = Date.now() + 10800000; // 3 hours from now
|
|
2112
|
+
* const result = await client.hpexpireat("my_hash", futureTimestamp, ["field1"], {
|
|
2113
|
+
* condition: HashExpirationCondition.ONLY_IF_GREATER_THAN_CURRENT
|
|
2114
|
+
* });
|
|
2115
|
+
* console.log(result); // [1] - expiration set because timestamp > current expiration
|
|
2116
|
+
* ```
|
|
2117
|
+
*/
|
|
2118
|
+
async hpexpireat(key, unixTimestampMilliseconds, fields, options) {
|
|
2119
|
+
return this.createWritePromise((0, _1.createHPExpireAt)(key, unixTimestampMilliseconds, fields, options));
|
|
2120
|
+
}
|
|
2121
|
+
/**
|
|
2122
|
+
* Returns the remaining time to live of hash fields that have a timeout, in seconds.
|
|
2123
|
+
*
|
|
2124
|
+
* @see {@link https://valkey.io/commands/httl/|valkey.io} for details.
|
|
2125
|
+
*
|
|
2126
|
+
* @param key - The key of the hash.
|
|
2127
|
+
* @param fields - The fields in the hash stored at `key` to retrieve the TTL for.
|
|
2128
|
+
* @returns An array of TTL values in seconds for the specified fields.
|
|
2129
|
+
* - For fields with a timeout, returns the remaining time in seconds.
|
|
2130
|
+
* - For fields that exist but have no associated expire, returns -1.
|
|
2131
|
+
* - For fields that do not exist, returns -2.
|
|
2132
|
+
*
|
|
2133
|
+
* @example
|
|
2134
|
+
* ```typescript
|
|
2135
|
+
* // Get TTL for hash fields
|
|
2136
|
+
* const result = await client.httl("my_hash", ["field1", "field2", "field3"]);
|
|
2137
|
+
* console.log(result); // [120, -1, -2] - field1 expires in 120 seconds, field2 has no expiration, field3 doesn't exist
|
|
2138
|
+
* ```
|
|
2139
|
+
*
|
|
2140
|
+
* @example
|
|
2141
|
+
* ```typescript
|
|
2142
|
+
* // Get TTL for a single field
|
|
2143
|
+
* const result = await client.httl("my_hash", ["field1"]);
|
|
2144
|
+
* console.log(result); // [60] - field1 expires in 60 seconds
|
|
2145
|
+
* ```
|
|
2146
|
+
*/
|
|
2147
|
+
async httl(key, fields) {
|
|
2148
|
+
return this.createWritePromise((0, _1.createHTtl)(key, fields));
|
|
2149
|
+
}
|
|
2150
|
+
/**
|
|
2151
|
+
* Returns the absolute Unix timestamp (in seconds) at which hash fields will expire.
|
|
2152
|
+
*
|
|
2153
|
+
* @see {@link https://valkey.io/commands/hexpiretime/|valkey.io} for details.
|
|
2154
|
+
*
|
|
2155
|
+
* @param key - The key of the hash.
|
|
2156
|
+
* @param fields - The list of fields to get the expiration timestamp for.
|
|
2157
|
+
* @returns An array of expiration timestamps in seconds for the specified fields:
|
|
2158
|
+
* - For fields with a timeout, returns the absolute Unix timestamp in seconds.
|
|
2159
|
+
* - For fields without a timeout, returns -1.
|
|
2160
|
+
* - For fields that do not exist, returns -2.
|
|
2161
|
+
*
|
|
2162
|
+
* @example
|
|
2163
|
+
* ```typescript
|
|
2164
|
+
* // Get expiration timestamps for hash fields
|
|
2165
|
+
* const result = await client.hexpiretime("my_hash", ["field1", "field2", "field3"]);
|
|
2166
|
+
* console.log(result); // [1672531200, -1, -2] - field1 expires at timestamp 1672531200, field2 has no expiration, field3 doesn't exist
|
|
2167
|
+
* ```
|
|
2168
|
+
*
|
|
2169
|
+
* @example
|
|
2170
|
+
* ```typescript
|
|
2171
|
+
* // Get expiration timestamp for a single field
|
|
2172
|
+
* const result = await client.hexpiretime("my_hash", ["field1"]);
|
|
2173
|
+
* console.log(result); // [1672531200] - field1 expires at timestamp 1672531200
|
|
2174
|
+
* ```
|
|
2175
|
+
*/
|
|
2176
|
+
async hexpiretime(key, fields) {
|
|
2177
|
+
return this.createWritePromise((0, _1.createHExpireTime)(key, fields));
|
|
2178
|
+
}
|
|
2179
|
+
/**
|
|
2180
|
+
* Returns the absolute Unix timestamp (in milliseconds) at which hash fields will expire.
|
|
2181
|
+
*
|
|
2182
|
+
* @see {@link https://valkey.io/commands/hpexpiretime/|valkey.io} for details.
|
|
2183
|
+
*
|
|
2184
|
+
* @param key - The key of the hash.
|
|
2185
|
+
* @param fields - The list of fields to get the expiration timestamp for.
|
|
2186
|
+
* @returns An array of expiration timestamps in milliseconds for the specified fields:
|
|
2187
|
+
* - For fields with a timeout, returns the absolute Unix timestamp in milliseconds.
|
|
2188
|
+
* - For fields without a timeout, returns -1.
|
|
2189
|
+
* - For fields that do not exist, returns -2.
|
|
2190
|
+
*
|
|
2191
|
+
* @example
|
|
2192
|
+
* ```typescript
|
|
2193
|
+
* // Get expiration timestamps for hash fields in milliseconds
|
|
2194
|
+
* const result = await client.hpexpiretime("my_hash", ["field1", "field2", "field3"]);
|
|
2195
|
+
* console.log(result); // [1672531200000, -1, -2] - field1 expires at timestamp 1672531200000, field2 has no expiration, field3 doesn't exist
|
|
2196
|
+
* ```
|
|
2197
|
+
*
|
|
2198
|
+
* @example
|
|
2199
|
+
* ```typescript
|
|
2200
|
+
* // Get expiration timestamp for a single field in milliseconds
|
|
2201
|
+
* const result = await client.hpexpiretime("my_hash", ["field1"]);
|
|
2202
|
+
* console.log(result); // [1672531200000] - field1 expires at timestamp 1672531200000
|
|
2203
|
+
* ```
|
|
2204
|
+
*/
|
|
2205
|
+
async hpexpiretime(key, fields) {
|
|
2206
|
+
return this.createWritePromise((0, _1.createHPExpireTime)(key, fields));
|
|
2207
|
+
}
|
|
2208
|
+
/**
|
|
2209
|
+
* Returns the remaining time to live of hash fields that have a timeout, in milliseconds.
|
|
2210
|
+
*
|
|
2211
|
+
* @see {@link https://valkey.io/commands/hpttl/|valkey.io} for details.
|
|
2212
|
+
*
|
|
2213
|
+
* @param key - The key of the hash.
|
|
2214
|
+
* @param fields - The list of fields to get the TTL for.
|
|
2215
|
+
* @returns An array of TTL values in milliseconds for the specified fields:
|
|
2216
|
+
* - For fields with a timeout, returns the remaining TTL in milliseconds.
|
|
2217
|
+
* - For fields without a timeout, returns -1.
|
|
2218
|
+
* - For fields that do not exist, returns -2.
|
|
2219
|
+
*
|
|
2220
|
+
* @example
|
|
2221
|
+
* ```typescript
|
|
2222
|
+
* // Get TTL for hash fields in milliseconds
|
|
2223
|
+
* const result = await client.hpttl("my_hash", ["field1", "field2", "field3"]);
|
|
2224
|
+
* console.log(result); // [120000, -1, -2] - field1 expires in 120000 ms, field2 has no expiration, field3 doesn't exist
|
|
2225
|
+
* ```
|
|
2226
|
+
*
|
|
2227
|
+
* @example
|
|
2228
|
+
* ```typescript
|
|
2229
|
+
* // Get TTL for a single field in milliseconds
|
|
2230
|
+
* const result = await client.hpttl("my_hash", ["field1"]);
|
|
2231
|
+
* console.log(result); // [60000] - field1 expires in 60000 ms
|
|
2232
|
+
* ```
|
|
2233
|
+
*/
|
|
2234
|
+
async hpttl(key, fields) {
|
|
2235
|
+
return this.createWritePromise((0, _1.createHPTtl)(key, fields));
|
|
2236
|
+
}
|
|
1797
2237
|
/** Inserts all the specified values at the head of the list stored at `key`.
|
|
1798
2238
|
* `elements` are inserted one after the other to the head of the list, from the leftmost element to the rightmost element.
|
|
1799
2239
|
* If `key` does not exist, it is created as empty list before performing the push operations.
|
|
@@ -6429,6 +6869,12 @@ class BaseClient {
|
|
|
6429
6869
|
}
|
|
6430
6870
|
: undefined;
|
|
6431
6871
|
const protocol = options.protocol;
|
|
6872
|
+
// Validate that clientAz is set when using AZ affinity strategies
|
|
6873
|
+
if ((options.readFrom === "AZAffinity" ||
|
|
6874
|
+
options.readFrom === "AZAffinityReplicasAndPrimary") &&
|
|
6875
|
+
!options.clientAz) {
|
|
6876
|
+
throw new _1.ConfigurationError(`clientAz must be set when readFrom is set to ${options.readFrom}`);
|
|
6877
|
+
}
|
|
6432
6878
|
return {
|
|
6433
6879
|
protocol,
|
|
6434
6880
|
clientName: options.clientName,
|
|
@@ -6440,6 +6886,7 @@ class BaseClient {
|
|
|
6440
6886
|
clusterModeEnabled: false,
|
|
6441
6887
|
readFrom,
|
|
6442
6888
|
authenticationInfo,
|
|
6889
|
+
databaseId: options.databaseId,
|
|
6443
6890
|
inflightRequestsLimit: options.inflightRequestsLimit,
|
|
6444
6891
|
clientAz: options.clientAz ?? null,
|
|
6445
6892
|
connectionRetryStrategy: options.connectionBackoff,
|