Refactor marketplace product fetching and caching logic; update environment configuration for Redis and PostgreSQL
This commit is contained in:
@@ -1,33 +1,14 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"github.com/go-faster/errors"
|
||||
"github.com/hibiken/asynq"
|
||||
"github.com/joho/godotenv"
|
||||
"github.com/redis/rueidis"
|
||||
"sipro-mps/internal/config"
|
||||
"sipro-mps/internal/redis"
|
||||
"sipro-mps/internal/tasks"
|
||||
"sipro-mps/internal/tasks/types"
|
||||
)
|
||||
|
||||
func main() {
|
||||
godotenv.Load()
|
||||
ctx := context.Background()
|
||||
|
||||
redis.InitClient(ctx)
|
||||
c := *redis.Client
|
||||
key := fmt.Sprintf("wb:products:%d", "test")
|
||||
v, err := c.Do(ctx, c.B().Get().Key(key).Build()).ToString()
|
||||
if err != nil {
|
||||
if errors.As(err, &rueidis.Nil) {
|
||||
fmt.Println("Key does not exist in Redis:", key)
|
||||
return
|
||||
}
|
||||
}
|
||||
fmt.Println("Value from Redis:", v)
|
||||
return
|
||||
cfg, err := config.LoadConfig()
|
||||
if err != nil {
|
||||
panic(err)
|
||||
@@ -39,7 +20,7 @@ func main() {
|
||||
panic(err)
|
||||
}
|
||||
}(client)
|
||||
task, err := tasks.NewFetchProductsTask(1130)
|
||||
task, err := types.NewFetchProductsTask(types.TypeOzonFetchProducts, 930)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user