Skip to content

Commit 14c8758

Browse files
committed
Use redis.
1 parent 85b8917 commit 14c8758

5 files changed

Lines changed: 14 additions & 0 deletions

File tree

cpp/deeplake_pg/pg_deeplake.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -368,6 +368,12 @@ void init_deeplake()
368368
constexpr int THREAD_POOL_MULTIPLIER = 8; // Threads per CPU core for async operations
369369
deeplake_api::initialize(std::make_shared<pg::logger_adapter>(), THREAD_POOL_MULTIPLIER * base::system_report::cpu_cores());
370370

371+
const std::string redis_url = base::getenv<std::string>("REDIS_URL", "");
372+
if (!redis_url.empty()) {
373+
deeplake_api::initialize_redis_cache(redis_url, 86400,
374+
deeplake_api::metadata_catalog_cache_pattern);
375+
}
376+
371377
pg::table_storage::instance(); /// initialize table storage
372378

373379
RegisterXactCallback(deeplake_xact_callback, nullptr);

serverless/docker-compose.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ services:
2121
DEEPLAKE_SYNC_INTERVAL_MS: ${DEEPLAKE_SYNC_INTERVAL_MS:-1000}
2222
PG_DEEPLAKE_MEMORY_LIMIT_MB: ${PG_DEEPLAKE_MEMORY_LIMIT_MB:-0}
2323
DEEPLAKE_STARTUP_JITTER_MAX_SECONDS: ${DEEPLAKE_STARTUP_JITTER_MAX_SECONDS:-0}
24+
REDIS_URL: redis://redis:6379
2425
entrypoint: ['/usr/local/bin/deeplake-entrypoint.sh']
2526
command: ['postgres']
2627
volumes:
@@ -67,6 +68,7 @@ services:
6768
DEEPLAKE_SYNC_INTERVAL_MS: ${DEEPLAKE_SYNC_INTERVAL_MS:-1000}
6869
PG_DEEPLAKE_MEMORY_LIMIT_MB: ${PG_DEEPLAKE_MEMORY_LIMIT_MB:-0}
6970
DEEPLAKE_STARTUP_JITTER_MAX_SECONDS: ${DEEPLAKE_STARTUP_JITTER_MAX_SECONDS:-0}
71+
REDIS_URL: redis://redis:6379
7072
entrypoint: ['/usr/local/bin/deeplake-entrypoint.sh']
7173
command: ['postgres']
7274
volumes:

serverless/helm/pg-deeplake/templates/statefulset.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,10 @@ spec:
134134
value: {{ .Values.deeplake.startupJitterMaxSeconds | quote }}
135135
- name: PGDATA
136136
value: /var/lib/postgresql/data/pgdata
137+
{{- if .Values.redis.enabled }}
138+
- name: REDIS_URL
139+
value: {{ .Values.redis.url | default (printf "redis://%s-redis:%d" (include "pg-deeplake.fullname" .) (int .Values.redis.service.port)) | quote }}
140+
{{- end }}
137141
{{- if .Values.envFromSecret }}
138142
envFrom:
139143
- secretRef:

serverless/helm/pg-deeplake/values.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,7 @@ haproxy:
185185

186186
redis:
187187
enabled: true
188+
url: "" # Auto-constructed from service name when empty
188189
image:
189190
repository: redis
190191
tag: "7-alpine"

serverless/scripts/manage.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -273,6 +273,7 @@ def generate_compose(n, profile="haproxy"):
273273
lines.append(" DEEPLAKE_SYNC_INTERVAL_MS: ${DEEPLAKE_SYNC_INTERVAL_MS:-1000}")
274274
lines.append(" PG_DEEPLAKE_MEMORY_LIMIT_MB: ${PG_DEEPLAKE_MEMORY_LIMIT_MB:-0}")
275275
lines.append(" DEEPLAKE_STARTUP_JITTER_MAX_SECONDS: ${DEEPLAKE_STARTUP_JITTER_MAX_SECONDS:-0}")
276+
lines.append(" REDIS_URL: redis://redis:6379")
276277
lines.append(" entrypoint: ['/usr/local/bin/deeplake-entrypoint.sh']")
277278
lines.append(" command: ['postgres']")
278279
lines.append(" volumes:")

0 commit comments

Comments
 (0)