@@ -524,12 +524,42 @@ func (c cmdable) Exists(ctx context.Context, keys ...string) *IntCmd {
524
524
return cmd
525
525
}
526
526
527
- func (c cmdable ) Expire (ctx context.Context , key string , expiration time.Duration ) * BoolCmd {
528
- cmd := NewBoolCmd (ctx , "expire" , key , formatSec (ctx , expiration ))
527
+ func (c cmdable ) expire (ctx context.Context , key string , expiration time.Duration , options ... interface {}) * BoolCmd {
528
+ args := make ([]interface {}, 3 + len (options ))
529
+ args [0 ] = "expire"
530
+ args [1 ] = key
531
+ args [2 ] = formatSec (ctx , expiration )
532
+ offset := 2
533
+
534
+ for i , option := range options {
535
+ args [i + offset ] = option
536
+ }
537
+
538
+ cmd := NewBoolCmd (ctx , args ... )
529
539
_ = c (ctx , cmd )
530
540
return cmd
531
541
}
532
542
543
+ func (c cmdable ) Expire (ctx context.Context , key string , expiration time.Duration ) * BoolCmd {
544
+ return c .expire (ctx , key , expiration )
545
+ }
546
+
547
+ func (c cmdable ) ExpireNX (ctx context.Context , key string , expiration time.Duration ) * BoolCmd {
548
+ return c .expire (ctx , key , expiration , "NX" )
549
+ }
550
+
551
+ func (c cmdable ) ExpireXX (ctx context.Context , key string , expiration time.Duration ) * BoolCmd {
552
+ return c .expire (ctx , key , expiration , "XX" )
553
+ }
554
+
555
+ func (c cmdable ) ExpireGT (ctx context.Context , key string , expiration time.Duration ) * BoolCmd {
556
+ return c .expire (ctx , key , expiration , "GT" )
557
+ }
558
+
559
+ func (c cmdable ) ExpireLT (ctx context.Context , key string , expiration time.Duration ) * BoolCmd {
560
+ return c .expire (ctx , key , expiration , "LT" )
561
+ }
562
+
533
563
func (c cmdable ) ExpireAt (ctx context.Context , key string , tm time.Time ) * BoolCmd {
534
564
cmd := NewBoolCmd (ctx , "expireat" , key , tm .Unix ())
535
565
_ = c (ctx , cmd )
0 commit comments