@@ -175,6 +175,11 @@ type CoreCmdable interface {
175
175
HPExpireTime (ctx context.Context , key string , fields ... string ) * IntSliceCmd
176
176
HTTL (ctx context.Context , key string , fields ... string ) * IntSliceCmd
177
177
HPTTL (ctx context.Context , key string , fields ... string ) * IntSliceCmd
178
+ HGetDel (ctx context.Context , key string , fields ... string ) * StringSliceCmd
179
+ HGetEX (ctx context.Context , key string , fields ... string ) * StringSliceCmd
180
+ HGetEXWithArgs (ctx context.Context , key string , options * HGetEXOptions , fields ... string ) * StringSliceCmd
181
+ HSetEX (ctx context.Context , key string , fieldsAndValues ... string ) * IntCmd
182
+ HSetEXWithArgs (ctx context.Context , key string , options * HSetEXOptions , fieldsAndValues ... string ) * IntCmd
178
183
179
184
BLPop (ctx context.Context , timeout time.Duration , keys ... string ) * StringSliceCmd
180
185
BLMPop (ctx context.Context , timeout time.Duration , direction string , count int64 , keys ... string ) * KeyValuesCmd
@@ -1555,6 +1560,92 @@ func (c *Compat) HPTTL(ctx context.Context, key string, fields ...string) *IntSl
1555
1560
return newIntSliceCmd (resp )
1556
1561
}
1557
1562
1563
+ func (c * Compat ) HGetDel (ctx context.Context , key string , fields ... string ) * StringSliceCmd {
1564
+ cmd := c .client .B ().Hgetdel ().Key (key ).Fields ().Numfields (int64 (len (fields ))).Field (fields ... ).Build ()
1565
+ resp := c .client .Do (ctx , cmd )
1566
+ return newStringSliceCmd (resp )
1567
+ }
1568
+
1569
+ func (c * Compat ) HGetEX (ctx context.Context , key string , fields ... string ) * StringSliceCmd {
1570
+ cmd := c .client .B ().Hgetex ().Key (key ).Fields ().Numfields (int64 (len (fields ))).Field (fields ... ).Build ()
1571
+ resp := c .client .Do (ctx , cmd )
1572
+ return newStringSliceCmd (resp )
1573
+ }
1574
+
1575
+ func (c * Compat ) HGetEXWithArgs (ctx context.Context , key string , options * HGetEXOptions , fields ... string ) * StringSliceCmd {
1576
+ if options == nil {
1577
+ return c .HGetEX (ctx , key , fields ... )
1578
+ }
1579
+
1580
+ var cmd rueidis.Completed
1581
+ if options .ExpirationType == HGetEXExpirationEX {
1582
+ cmd = c .client .B ().Hgetex ().Key (key ).Ex (options .ExpirationVal ).Fields ().Numfields (int64 (len (fields ))).Field (fields ... ).Build ()
1583
+ } else if options .ExpirationType == HGetEXExpirationPX {
1584
+ cmd = c .client .B ().Hgetex ().Key (key ).Px (options .ExpirationVal ).Fields ().Numfields (int64 (len (fields ))).Field (fields ... ).Build ()
1585
+ } else if options .ExpirationType == HGetEXExpirationEXAT {
1586
+ cmd = c .client .B ().Hgetex ().Key (key ).Exat (options .ExpirationVal ).Fields ().Numfields (int64 (len (fields ))).Field (fields ... ).Build ()
1587
+ } else if options .ExpirationType == HGetEXExpirationPXAT {
1588
+ cmd = c .client .B ().Hgetex ().Key (key ).Pxat (options .ExpirationVal ).Fields ().Numfields (int64 (len (fields ))).Field (fields ... ).Build ()
1589
+ } else if options .ExpirationType == HGetEXExpirationPERSIST {
1590
+ cmd = c .client .B ().Hgetex ().Key (key ).Persist ().Fields ().Numfields (int64 (len (fields ))).Field (fields ... ).Build ()
1591
+ }
1592
+ resp := c .client .Do (ctx , cmd )
1593
+ return newStringSliceCmd (resp )
1594
+ }
1595
+
1596
+ func (c * Compat ) HSetEX (ctx context.Context , key string , fieldsAndValues ... string ) * IntCmd {
1597
+ partial := c .client .B ().Hsetex ().Key (key ).Fields ().Numfields (int64 (len (fieldsAndValues ) / 2 )).FieldValue ()
1598
+
1599
+ for i := 0 ; i < len (fieldsAndValues ); i += 2 {
1600
+ partial = partial .FieldValue (fieldsAndValues [i ], fieldsAndValues [i + 1 ])
1601
+ }
1602
+ cmd := partial .Build ()
1603
+
1604
+ resp := c .client .Do (ctx , cmd )
1605
+ return newIntCmd (resp )
1606
+ }
1607
+
1608
+ func (c * Compat ) HSetEXWithArgs (ctx context.Context , key string , options * HSetEXOptions , fieldsAndValues ... string ) * IntCmd {
1609
+ if options == nil {
1610
+ return c .HSetEX (ctx , key , fieldsAndValues ... )
1611
+ }
1612
+
1613
+ var partial cmds.HsetexFieldValue
1614
+ if options .Condition == HSetEXFNX {
1615
+ if options .ExpirationType == HSetEXExpirationEX {
1616
+ partial = c .client .B ().Hsetex ().Key (key ).Fnx ().Ex (options .ExpirationVal ).Fields ().Numfields (int64 (len (fieldsAndValues ) / 2 )).FieldValue ()
1617
+ } else if options .ExpirationType == HSetEXExpirationPX {
1618
+ partial = c .client .B ().Hsetex ().Key (key ).Fnx ().Px (options .ExpirationVal ).Fields ().Numfields (int64 (len (fieldsAndValues ) / 2 )).FieldValue ()
1619
+ } else if options .ExpirationType == HSetEXExpirationEXAT {
1620
+ partial = c .client .B ().Hsetex ().Key (key ).Fnx ().Exat (options .ExpirationVal ).Fields ().Numfields (int64 (len (fieldsAndValues ) / 2 )).FieldValue ()
1621
+ } else if options .ExpirationType == HSetEXExpirationPXAT {
1622
+ partial = c .client .B ().Hsetex ().Key (key ).Fnx ().Pxat (options .ExpirationVal ).Fields ().Numfields (int64 (len (fieldsAndValues ) / 2 )).FieldValue ()
1623
+ } else if options .ExpirationType == HSetEXExpirationKEEPTTL {
1624
+ partial = c .client .B ().Hsetex ().Key (key ).Fnx ().Keepttl ().Fields ().Numfields (int64 (len (fieldsAndValues ) / 2 )).FieldValue ()
1625
+ }
1626
+ } else if options .Condition == HSetEXFXX {
1627
+ if options .ExpirationType == HSetEXExpirationEX {
1628
+ partial = c .client .B ().Hsetex ().Key (key ).Fxx ().Ex (options .ExpirationVal ).Fields ().Numfields (int64 (len (fieldsAndValues ) / 2 )).FieldValue ()
1629
+ } else if options .ExpirationType == HSetEXExpirationPX {
1630
+ partial = c .client .B ().Hsetex ().Key (key ).Fxx ().Px (options .ExpirationVal ).Fields ().Numfields (int64 (len (fieldsAndValues ) / 2 )).FieldValue ()
1631
+ } else if options .ExpirationType == HSetEXExpirationEXAT {
1632
+ partial = c .client .B ().Hsetex ().Key (key ).Fxx ().Exat (options .ExpirationVal ).Fields ().Numfields (int64 (len (fieldsAndValues ) / 2 )).FieldValue ()
1633
+ } else if options .ExpirationType == HSetEXExpirationPXAT {
1634
+ partial = c .client .B ().Hsetex ().Key (key ).Fxx ().Pxat (options .ExpirationVal ).Fields ().Numfields (int64 (len (fieldsAndValues ) / 2 )).FieldValue ()
1635
+ } else if options .ExpirationType == HSetEXExpirationKEEPTTL {
1636
+ partial = c .client .B ().Hsetex ().Key (key ).Fxx ().Keepttl ().Fields ().Numfields (int64 (len (fieldsAndValues ) / 2 )).FieldValue ()
1637
+ }
1638
+ }
1639
+
1640
+ for i := 0 ; i < len (fieldsAndValues ); i += 2 {
1641
+ partial = partial .FieldValue (fieldsAndValues [i ], fieldsAndValues [i + 1 ])
1642
+ }
1643
+
1644
+ cmd := partial .Build ()
1645
+ resp := c .client .Do (ctx , cmd )
1646
+ return newIntCmd (resp )
1647
+ }
1648
+
1558
1649
func (c * Compat ) BLPop (ctx context.Context , timeout time.Duration , keys ... string ) * StringSliceCmd {
1559
1650
cmd := c .client .B ().Blpop ().Key (keys ... ).Timeout (float64 (formatSec (timeout ))).Build ()
1560
1651
resp := c .client .Do (ctx , cmd )
0 commit comments