Compare commits
2 Commits
dev
...
cashe-more
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
497b5a6e86 | ||
|
|
8b56bf8370 |
61
docker-compose.yaml
Normal file
61
docker-compose.yaml
Normal file
@@ -0,0 +1,61 @@
|
||||
services:
|
||||
db:
|
||||
image: postgres:17.2
|
||||
container_name: postgres-db
|
||||
environment:
|
||||
POSTGRES_USER: postgres
|
||||
POSTGRES_PASSWORD: RootPassword
|
||||
POSTGRES_DB: ti1
|
||||
ports:
|
||||
- "5432:5432"
|
||||
volumes:
|
||||
- /tmp/ti1/postgres_data:/var/lib/postgresql/data:z
|
||||
- /tmp/ti1/init.sql:/docker-entrypoint-initdb.d/init.sql:ro,z
|
||||
networks:
|
||||
- app-network
|
||||
healthcheck:
|
||||
test: ["CMD", "pg_isready", "-U", "postgres", "-d", "ti1", "-h", "db"]
|
||||
interval: 10s
|
||||
retries: 5
|
||||
restart: always
|
||||
|
||||
valkey:
|
||||
image: valkey/valkey:latest
|
||||
container_name: valkey
|
||||
environment:
|
||||
VALKEY_PASSWORD: the_valkey_password
|
||||
ports:
|
||||
- "6379:6379"
|
||||
volumes:
|
||||
- /tmp/ti1/valkey_data:/data:z
|
||||
networks:
|
||||
- app-network
|
||||
restart: always
|
||||
|
||||
ti1-container:
|
||||
build:
|
||||
context: .
|
||||
dockerfile: Dockerfile
|
||||
container_name: ti1-container
|
||||
environment:
|
||||
DB_HOST: db
|
||||
DB_PORT: 5432
|
||||
DB_USER: postgres
|
||||
DB_PASSWORD: RootPassword
|
||||
DB_NAME: ti1
|
||||
DB_SSLMODE: disable
|
||||
VALKEY_HOST: valkey
|
||||
VALKEY_PORT: 6379
|
||||
VALKEY_PASSWORD: the_valkey_password
|
||||
depends_on:
|
||||
db:
|
||||
condition: service_healthy
|
||||
valkey:
|
||||
condition: service_started
|
||||
networks:
|
||||
- app-network
|
||||
restart: always
|
||||
|
||||
networks:
|
||||
app-network:
|
||||
driver: bridge
|
||||
@@ -9,13 +9,15 @@ import (
|
||||
)
|
||||
|
||||
func SetValkeyValue(ctx context.Context, client valkey.Client, key, value string) error {
|
||||
err := client.Do(ctx, client.B().Set().Key(key).Value(value).Ex(time.Hour).Build()).Error()
|
||||
err := client.Do(ctx, client.B().Set().Key(key).Value(value).Ex(90*time.Minute).Build()).Error()
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to set value in Valkey: %v", err)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
|
||||
|
||||
func GetValkeyValue(ctx context.Context, client valkey.Client, key string) (string, error) {
|
||||
value, err := client.Do(ctx, client.B().Get().Key(key).Build()).ToString()
|
||||
if err != nil {
|
||||
|
||||
Reference in New Issue
Block a user