package commands import ( "errors" "redisClone/pkg/core" "strconv" "time" ) func Expire(args []string, getShard func(k string) *core.Shard) interface{} { key := args[1] seconds, err := strconv.Atoi(args[2]) if err != nil { return errors.New("value is not an integer") } s := getShard(key) item, exists := s.Data[key] if !exists { return 0 } expiry := time.Now().Add(time.Duration(seconds) * time.Second) item.ExpiresAt = &expiry s.Data[key] = item return 1 }