Skip to content

Commit f9cb05f

Browse files
Decouple demo Redis caching from prod caching
1 parent e4aab97 commit f9cb05f

File tree

4 files changed

+24
-5
lines changed

4 files changed

+24
-5
lines changed

deploy/deployctl/subcommands/browser_deployments.py

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,19 @@
105105
spec:
106106
nodeSelector:
107107
cloud.google.com/gke-nodepool: 'demo-pool'
108+
- patch: |-
109+
apiVersion: apps/v1
110+
kind: Deployment
111+
metadata:
112+
name: gnomad-api
113+
spec:
114+
template:
115+
spec:
116+
containers:
117+
- name: app
118+
env:
119+
- name: REDIS_CACHE_PREFIX
120+
value: '{deployment_name}'
108121
"""
109122

110123

@@ -193,7 +206,7 @@ def create_deployment(name: str, browser_tag: str = None, api_tag: str = None, d
193206
)
194207

195208
if demo:
196-
kustomization = kustomization + DEMO_DEPLOYMENT_KUSTOMIZATION
209+
kustomization = kustomization + DEMO_DEPLOYMENT_KUSTOMIZATION.format(deployment_name=name)
197210

198211
kustomization_file.write(kustomization)
199212

deploy/manifests/browser/base/api.deployment.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,8 @@ spec:
6161
value: 'true'
6262
- name: NODE_OPTIONS
6363
value: '--max-old-space-size=10240'
64+
- name: REDIS_CACHE_PREFIX
65+
value: 'production'
6466
ports:
6567
- name: http
6668
containerPort: 8000

graphql-api/src/cache.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,8 +90,11 @@ export const withCache = (
9090
jsonCacheLargeGenes = config.JSON_CACHE_LARGE_GENES,
9191
} = options
9292

93+
const redisCachePrefix = config.REDIS_CACHE_PREFIX
94+
9395
return async (...args: any[]) => {
94-
const cacheKey = keyFn(...args)
96+
const unscopedCacheKey = keyFn(...args)
97+
const cacheKey = `${redisCachePrefix}:${unscopedCacheKey}`
9598

9699
if (jsonCacheEnableAll) {
97100
const json_cache = new JsonCache(config.JSON_CACHE_PATH, config.JSON_CACHE_COMPRESSION)

graphql-api/src/config.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,10 @@ const config: Record<string, any> = {
4444

4545
// JSON caching
4646
JSON_CACHE_PATH: env.JSON_CACHE_PATH,
47-
JSON_CACHE_ENABLE_ALL: env.JSON_CACHE_ENABLE_ALL === "true" || false,
48-
JSON_CACHE_LARGE_GENES: env.JSON_CACHE_LARGE_GENES === "true" || false,
49-
JSON_CACHE_COMPRESSION: env.JSON_CACHE_COMPRESSION === "true" || false
47+
JSON_CACHE_ENABLE_ALL: env.JSON_CACHE_ENABLE_ALL === 'true' || false,
48+
JSON_CACHE_LARGE_GENES: env.JSON_CACHE_LARGE_GENES === 'true' || false,
49+
JSON_CACHE_COMPRESSION: env.JSON_CACHE_COMPRESSION === 'true' || false,
50+
REDIS_CACHE_PREFIX: env.REDIS_CACHE_PREFIX || '',
5051
}
5152

5253
const requiredConfig = ['ELASTICSEARCH_URL']

0 commit comments

Comments
 (0)