container-superposition 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (327) hide show
  1. package/README.md +843 -0
  2. package/dist/scripts/init.d.ts +3 -0
  3. package/dist/scripts/init.d.ts.map +1 -0
  4. package/dist/scripts/init.js +1190 -0
  5. package/dist/scripts/init.js.map +1 -0
  6. package/dist/scripts/migrate-to-manifests.d.ts +12 -0
  7. package/dist/scripts/migrate-to-manifests.d.ts.map +1 -0
  8. package/dist/scripts/migrate-to-manifests.js +230 -0
  9. package/dist/scripts/migrate-to-manifests.js.map +1 -0
  10. package/dist/tool/questionnaire/composer.d.ts +6 -0
  11. package/dist/tool/questionnaire/composer.d.ts.map +1 -0
  12. package/dist/tool/questionnaire/composer.js +1232 -0
  13. package/dist/tool/questionnaire/composer.js.map +1 -0
  14. package/dist/tool/readme/markdown-parser.d.ts +30 -0
  15. package/dist/tool/readme/markdown-parser.d.ts.map +1 -0
  16. package/dist/tool/readme/markdown-parser.js +139 -0
  17. package/dist/tool/readme/markdown-parser.js.map +1 -0
  18. package/dist/tool/readme/readme-generator.d.ts +9 -0
  19. package/dist/tool/readme/readme-generator.d.ts.map +1 -0
  20. package/dist/tool/readme/readme-generator.js +422 -0
  21. package/dist/tool/readme/readme-generator.js.map +1 -0
  22. package/dist/tool/schema/custom-loader.d.ts +17 -0
  23. package/dist/tool/schema/custom-loader.d.ts.map +1 -0
  24. package/dist/tool/schema/custom-loader.js +149 -0
  25. package/dist/tool/schema/custom-loader.js.map +1 -0
  26. package/dist/tool/schema/overlay-loader.d.ts +47 -0
  27. package/dist/tool/schema/overlay-loader.d.ts.map +1 -0
  28. package/dist/tool/schema/overlay-loader.js +252 -0
  29. package/dist/tool/schema/overlay-loader.js.map +1 -0
  30. package/dist/tool/schema/types.d.ts +212 -0
  31. package/dist/tool/schema/types.d.ts.map +1 -0
  32. package/dist/tool/schema/types.js +5 -0
  33. package/dist/tool/schema/types.js.map +1 -0
  34. package/docs/README.md +308 -0
  35. package/docs/architecture.md +233 -0
  36. package/docs/creating-overlays.md +549 -0
  37. package/docs/custom-patches.md +540 -0
  38. package/docs/dependencies.md +279 -0
  39. package/docs/examples/custom-patches-example.md +85 -0
  40. package/docs/examples.md +576 -0
  41. package/docs/messaging-comparison.md +265 -0
  42. package/docs/messaging-quick-start.md +385 -0
  43. package/docs/observability-workflow.md +537 -0
  44. package/docs/overlay-manifest-refactoring.md +214 -0
  45. package/docs/overlay-metadata-archive.md +54 -0
  46. package/docs/overlays.md +523 -0
  47. package/docs/presets-architecture.md +498 -0
  48. package/docs/presets.md +366 -0
  49. package/docs/publishing.md +476 -0
  50. package/docs/quick-reference.md +326 -0
  51. package/docs/ux.md +170 -0
  52. package/features/README.md +85 -0
  53. package/features/cross-distro-packages/README.md +146 -0
  54. package/features/cross-distro-packages/devcontainer-feature.json +20 -0
  55. package/features/cross-distro-packages/install.sh +58 -0
  56. package/features/local-secrets-manager/devcontainer-feature.json +18 -0
  57. package/features/local-secrets-manager/install.sh +127 -0
  58. package/features/project-scaffolder/devcontainer-feature.json +24 -0
  59. package/features/project-scaffolder/install.sh +100 -0
  60. package/features/team-conventions/devcontainer-feature.json +24 -0
  61. package/features/team-conventions/install.sh +93 -0
  62. package/overlays/.registry/README.md +14 -0
  63. package/overlays/.registry/base-images.yml +26 -0
  64. package/overlays/.registry/base-templates.yml +7 -0
  65. package/overlays/README.md +155 -0
  66. package/overlays/alertmanager/.env.example +5 -0
  67. package/overlays/alertmanager/README.md +465 -0
  68. package/overlays/alertmanager/alert-rules.yml +56 -0
  69. package/overlays/alertmanager/alertmanager.yml +42 -0
  70. package/overlays/alertmanager/devcontainer.patch.json +12 -0
  71. package/overlays/alertmanager/docker-compose.yml +20 -0
  72. package/overlays/alertmanager/overlay.yml +17 -0
  73. package/overlays/alertmanager/setup.sh +53 -0
  74. package/overlays/alertmanager/verify.sh +31 -0
  75. package/overlays/aws-cli/README.md +473 -0
  76. package/overlays/aws-cli/devcontainer.patch.json +13 -0
  77. package/overlays/aws-cli/overlay.yml +13 -0
  78. package/overlays/azure-cli/README.md +551 -0
  79. package/overlays/azure-cli/devcontainer.patch.json +8 -0
  80. package/overlays/azure-cli/overlay.yml +13 -0
  81. package/overlays/bun/README.md +312 -0
  82. package/overlays/bun/devcontainer.patch.json +41 -0
  83. package/overlays/bun/overlay.yml +16 -0
  84. package/overlays/bun/setup.sh +79 -0
  85. package/overlays/bun/verify.sh +30 -0
  86. package/overlays/codex/README.md +128 -0
  87. package/overlays/codex/devcontainer.patch.json +3 -0
  88. package/overlays/codex/overlay.yml +14 -0
  89. package/overlays/codex/setup.sh +24 -0
  90. package/overlays/codex/verify.sh +30 -0
  91. package/overlays/commitlint/README.md +333 -0
  92. package/overlays/commitlint/devcontainer.patch.json +8 -0
  93. package/overlays/commitlint/overlay.yml +16 -0
  94. package/overlays/commitlint/setup.sh +234 -0
  95. package/overlays/direnv/README.md +504 -0
  96. package/overlays/direnv/devcontainer.patch.json +6 -0
  97. package/overlays/direnv/overlay.yml +13 -0
  98. package/overlays/direnv/setup.sh +139 -0
  99. package/overlays/docker-in-docker/README.md +534 -0
  100. package/overlays/docker-in-docker/devcontainer.patch.json +10 -0
  101. package/overlays/docker-in-docker/overlay.yml +13 -0
  102. package/overlays/docker-sock/README.md +256 -0
  103. package/overlays/docker-sock/devcontainer.patch.json +9 -0
  104. package/overlays/docker-sock/docker-compose.yml +8 -0
  105. package/overlays/docker-sock/overlay.yml +13 -0
  106. package/overlays/dotnet/README.md +147 -0
  107. package/overlays/dotnet/devcontainer.patch.json +51 -0
  108. package/overlays/dotnet/global-tools.txt +24 -0
  109. package/overlays/dotnet/overlay.yml +13 -0
  110. package/overlays/dotnet/setup.sh +51 -0
  111. package/overlays/dotnet/verify.sh +26 -0
  112. package/overlays/gcloud/README.md +269 -0
  113. package/overlays/gcloud/devcontainer.patch.json +14 -0
  114. package/overlays/gcloud/overlay.yml +14 -0
  115. package/overlays/gcloud/verify.sh +52 -0
  116. package/overlays/git-helpers/README.md +168 -0
  117. package/overlays/git-helpers/devcontainer.patch.json +33 -0
  118. package/overlays/git-helpers/overlay.yml +15 -0
  119. package/overlays/git-helpers/setup.sh +91 -0
  120. package/overlays/go/README.md +293 -0
  121. package/overlays/go/devcontainer.patch.json +43 -0
  122. package/overlays/go/overlay.yml +15 -0
  123. package/overlays/go/setup.sh +33 -0
  124. package/overlays/go/verify.sh +40 -0
  125. package/overlays/grafana/.env.example +9 -0
  126. package/overlays/grafana/README.md +462 -0
  127. package/overlays/grafana/dashboard-provider.yml +11 -0
  128. package/overlays/grafana/dashboards/observability-overview.json +263 -0
  129. package/overlays/grafana/devcontainer.patch.json +12 -0
  130. package/overlays/grafana/docker-compose.yml +27 -0
  131. package/overlays/grafana/grafana-datasources.yml +57 -0
  132. package/overlays/grafana/overlay.yml +21 -0
  133. package/overlays/grafana/verify.sh +34 -0
  134. package/overlays/jaeger/.env.example +7 -0
  135. package/overlays/jaeger/README.md +867 -0
  136. package/overlays/jaeger/devcontainer.patch.json +12 -0
  137. package/overlays/jaeger/docker-compose.yml +17 -0
  138. package/overlays/jaeger/overlay.yml +19 -0
  139. package/overlays/java/README.md +267 -0
  140. package/overlays/java/devcontainer.patch.json +44 -0
  141. package/overlays/java/overlay.yml +16 -0
  142. package/overlays/java/setup.sh +41 -0
  143. package/overlays/java/verify.sh +42 -0
  144. package/overlays/just/README.md +443 -0
  145. package/overlays/just/devcontainer.patch.json +3 -0
  146. package/overlays/just/overlay.yml +13 -0
  147. package/overlays/just/setup.sh +182 -0
  148. package/overlays/kubectl-helm/README.md +660 -0
  149. package/overlays/kubectl-helm/devcontainer.patch.json +10 -0
  150. package/overlays/kubectl-helm/overlay.yml +13 -0
  151. package/overlays/loki/.env.example +5 -0
  152. package/overlays/loki/README.md +1156 -0
  153. package/overlays/loki/devcontainer.patch.json +12 -0
  154. package/overlays/loki/docker-compose.yml +18 -0
  155. package/overlays/loki/loki-config.yaml +45 -0
  156. package/overlays/loki/overlay.yml +17 -0
  157. package/overlays/minio/.env.example +9 -0
  158. package/overlays/minio/README.md +639 -0
  159. package/overlays/minio/devcontainer.patch.json +30 -0
  160. package/overlays/minio/docker-compose.yml +28 -0
  161. package/overlays/minio/overlay.yml +18 -0
  162. package/overlays/minio/setup.sh +61 -0
  163. package/overlays/minio/verify.sh +64 -0
  164. package/overlays/mkdocs/README.md +309 -0
  165. package/overlays/mkdocs/devcontainer.patch.json +24 -0
  166. package/overlays/mkdocs/overlay.yml +15 -0
  167. package/overlays/modern-cli-tools/README.md +556 -0
  168. package/overlays/modern-cli-tools/devcontainer.patch.json +3 -0
  169. package/overlays/modern-cli-tools/overlay.yml +13 -0
  170. package/overlays/modern-cli-tools/setup.sh +153 -0
  171. package/overlays/mongodb/.env.example +9 -0
  172. package/overlays/mongodb/README.md +481 -0
  173. package/overlays/mongodb/devcontainer.patch.json +32 -0
  174. package/overlays/mongodb/docker-compose.yml +44 -0
  175. package/overlays/mongodb/overlay.yml +17 -0
  176. package/overlays/mongodb/verify.sh +48 -0
  177. package/overlays/mysql/.env.example +11 -0
  178. package/overlays/mysql/README.md +542 -0
  179. package/overlays/mysql/devcontainer.patch.json +34 -0
  180. package/overlays/mysql/docker-compose.yml +55 -0
  181. package/overlays/mysql/overlay.yml +16 -0
  182. package/overlays/mysql/verify.sh +48 -0
  183. package/overlays/nats/.env.example +5 -0
  184. package/overlays/nats/README.md +762 -0
  185. package/overlays/nats/devcontainer.patch.json +24 -0
  186. package/overlays/nats/docker-compose.yml +31 -0
  187. package/overlays/nats/overlay.yml +18 -0
  188. package/overlays/nats/verify.sh +50 -0
  189. package/overlays/ngrok/README.md +503 -0
  190. package/overlays/ngrok/devcontainer.patch.json +3 -0
  191. package/overlays/ngrok/overlay.yml +14 -0
  192. package/overlays/ngrok/setup.sh +125 -0
  193. package/overlays/nodejs/README.md +192 -0
  194. package/overlays/nodejs/devcontainer.patch.json +49 -0
  195. package/overlays/nodejs/global-packages.txt +16 -0
  196. package/overlays/nodejs/overlay.yml +14 -0
  197. package/overlays/nodejs/setup.sh +46 -0
  198. package/overlays/nodejs/verify.sh +32 -0
  199. package/overlays/otel-collector/.env.example +9 -0
  200. package/overlays/otel-collector/README.md +1257 -0
  201. package/overlays/otel-collector/devcontainer.patch.json +28 -0
  202. package/overlays/otel-collector/docker-compose.yml +22 -0
  203. package/overlays/otel-collector/otel-collector-config.yaml +68 -0
  204. package/overlays/otel-collector/overlay.yml +21 -0
  205. package/overlays/otel-collector/setup.sh +49 -0
  206. package/overlays/otel-demo-nodejs/.env.example +2 -0
  207. package/overlays/otel-demo-nodejs/Dockerfile-otel-demo-nodejs +17 -0
  208. package/overlays/otel-demo-nodejs/README.md +409 -0
  209. package/overlays/otel-demo-nodejs/devcontainer.patch.json +12 -0
  210. package/overlays/otel-demo-nodejs/docker-compose.yml +19 -0
  211. package/overlays/otel-demo-nodejs/overlay.yml +23 -0
  212. package/overlays/otel-demo-nodejs/package-otel-demo-nodejs.json +20 -0
  213. package/overlays/otel-demo-nodejs/server-otel-demo-nodejs.js +259 -0
  214. package/overlays/otel-demo-nodejs/tracing-otel-demo-nodejs.js +57 -0
  215. package/overlays/otel-demo-nodejs/verify.sh +31 -0
  216. package/overlays/otel-demo-python/.env.example +2 -0
  217. package/overlays/otel-demo-python/Dockerfile-otel-demo-python +16 -0
  218. package/overlays/otel-demo-python/README.md +82 -0
  219. package/overlays/otel-demo-python/app-otel-demo-python.py +208 -0
  220. package/overlays/otel-demo-python/devcontainer.patch.json +12 -0
  221. package/overlays/otel-demo-python/docker-compose.yml +19 -0
  222. package/overlays/otel-demo-python/overlay.yml +23 -0
  223. package/overlays/otel-demo-python/requirements-otel-demo-python.txt +4 -0
  224. package/overlays/otel-demo-python/verify.sh +31 -0
  225. package/overlays/playwright/README.md +629 -0
  226. package/overlays/playwright/devcontainer.patch.json +9 -0
  227. package/overlays/playwright/overlay.yml +13 -0
  228. package/overlays/postgres/.env.example +6 -0
  229. package/overlays/postgres/README.md +602 -0
  230. package/overlays/postgres/devcontainer.patch.json +21 -0
  231. package/overlays/postgres/docker-compose.yml +22 -0
  232. package/overlays/postgres/overlay.yml +15 -0
  233. package/overlays/postgres/verify.sh +45 -0
  234. package/overlays/powershell/README.md +314 -0
  235. package/overlays/powershell/devcontainer.patch.json +22 -0
  236. package/overlays/powershell/overlay.yml +13 -0
  237. package/overlays/powershell/setup.sh +29 -0
  238. package/overlays/powershell/verify.sh +38 -0
  239. package/overlays/pre-commit/README.md +263 -0
  240. package/overlays/pre-commit/devcontainer.patch.json +9 -0
  241. package/overlays/pre-commit/overlay.yml +16 -0
  242. package/overlays/pre-commit/setup.sh +129 -0
  243. package/overlays/presets/docs-site.yml +118 -0
  244. package/overlays/presets/fullstack.yml +181 -0
  245. package/overlays/presets/microservice.yml +118 -0
  246. package/overlays/presets/web-api.yml +109 -0
  247. package/overlays/prometheus/.env.example +5 -0
  248. package/overlays/prometheus/README.md +1246 -0
  249. package/overlays/prometheus/devcontainer.patch.json +12 -0
  250. package/overlays/prometheus/docker-compose.yml +22 -0
  251. package/overlays/prometheus/overlay.yml +17 -0
  252. package/overlays/prometheus/prometheus.yml +12 -0
  253. package/overlays/prometheus/verify.sh +34 -0
  254. package/overlays/promtail/.env.example +2 -0
  255. package/overlays/promtail/README.md +357 -0
  256. package/overlays/promtail/devcontainer.patch.json +5 -0
  257. package/overlays/promtail/docker-compose.yml +16 -0
  258. package/overlays/promtail/overlay.yml +17 -0
  259. package/overlays/promtail/promtail-config.yaml +60 -0
  260. package/overlays/promtail/verify.sh +31 -0
  261. package/overlays/pulumi/README.md +472 -0
  262. package/overlays/pulumi/devcontainer.patch.json +13 -0
  263. package/overlays/pulumi/overlay.yml +14 -0
  264. package/overlays/pulumi/verify.sh +31 -0
  265. package/overlays/python/README.md +919 -0
  266. package/overlays/python/devcontainer.patch.json +41 -0
  267. package/overlays/python/overlay.yml +12 -0
  268. package/overlays/python/requirements-overlay.txt +13 -0
  269. package/overlays/python/setup.sh +47 -0
  270. package/overlays/python/verify.sh +32 -0
  271. package/overlays/rabbitmq/.env.example +7 -0
  272. package/overlays/rabbitmq/README.md +680 -0
  273. package/overlays/rabbitmq/devcontainer.patch.json +28 -0
  274. package/overlays/rabbitmq/docker-compose.yml +30 -0
  275. package/overlays/rabbitmq/overlay.yml +18 -0
  276. package/overlays/rabbitmq/verify.sh +41 -0
  277. package/overlays/redis/.env.example +4 -0
  278. package/overlays/redis/README.md +776 -0
  279. package/overlays/redis/devcontainer.patch.json +21 -0
  280. package/overlays/redis/docker-compose.yml +21 -0
  281. package/overlays/redis/overlay.yml +15 -0
  282. package/overlays/redis/verify.sh +41 -0
  283. package/overlays/redpanda/.env.example +10 -0
  284. package/overlays/redpanda/README.md +703 -0
  285. package/overlays/redpanda/devcontainer.patch.json +37 -0
  286. package/overlays/redpanda/docker-compose.yml +67 -0
  287. package/overlays/redpanda/overlay.yml +21 -0
  288. package/overlays/redpanda/verify.sh +48 -0
  289. package/overlays/rust/README.md +299 -0
  290. package/overlays/rust/devcontainer.patch.json +39 -0
  291. package/overlays/rust/overlay.yml +15 -0
  292. package/overlays/rust/setup.sh +36 -0
  293. package/overlays/rust/verify.sh +51 -0
  294. package/overlays/sqlite/README.md +584 -0
  295. package/overlays/sqlite/devcontainer.patch.json +14 -0
  296. package/overlays/sqlite/overlay.yml +15 -0
  297. package/overlays/sqlite/setup.sh +27 -0
  298. package/overlays/sqlite/verify.sh +43 -0
  299. package/overlays/sqlserver/.env.example +6 -0
  300. package/overlays/sqlserver/README.md +592 -0
  301. package/overlays/sqlserver/devcontainer.patch.json +22 -0
  302. package/overlays/sqlserver/docker-compose.yml +32 -0
  303. package/overlays/sqlserver/overlay.yml +17 -0
  304. package/overlays/sqlserver/verify.sh +30 -0
  305. package/overlays/tempo/.env.example +5 -0
  306. package/overlays/tempo/README.md +273 -0
  307. package/overlays/tempo/devcontainer.patch.json +12 -0
  308. package/overlays/tempo/docker-compose.yml +20 -0
  309. package/overlays/tempo/overlay.yml +20 -0
  310. package/overlays/tempo/tempo-config.yaml +32 -0
  311. package/overlays/tempo/verify.sh +31 -0
  312. package/overlays/terraform/README.md +389 -0
  313. package/overlays/terraform/devcontainer.patch.json +15 -0
  314. package/overlays/terraform/overlay.yml +14 -0
  315. package/overlays/terraform/verify.sh +63 -0
  316. package/package.json +74 -0
  317. package/templates/README.md +285 -0
  318. package/templates/compose/.devcontainer/devcontainer.json +46 -0
  319. package/templates/compose/.devcontainer/docker-compose.yml +12 -0
  320. package/templates/compose/README.md +20 -0
  321. package/templates/plain/.devcontainer/devcontainer.json +35 -0
  322. package/templates/plain/README.md +21 -0
  323. package/tool/README.md +281 -0
  324. package/tool/schema/base-images.schema.json +43 -0
  325. package/tool/schema/base-templates.schema.json +34 -0
  326. package/tool/schema/config.schema.json +71 -0
  327. package/tool/schema/overlay-manifest.schema.json +86 -0
@@ -0,0 +1,776 @@
1
+ # Redis Overlay
2
+
3
+ Redis 7 in-memory data store for caching, session management, and real-time applications.
4
+
5
+ ## Features
6
+
7
+ - **Redis 7** - Latest major version with modern features
8
+ - **Pre-configured** - Ready to use with sensible defaults
9
+ - **Docker Compose service** - Runs as separate container
10
+ - **Persistent storage** - Optional data persistence
11
+ - **Redis CLI** - Command-line interface for interaction
12
+ - **Environment configuration** - Customizable via `.env` file
13
+
14
+ ## How It Works
15
+
16
+ This overlay adds a Redis 7 server as a separate Docker Compose service. Redis runs in its own container and is accessible from your development container via the hostname `redis`.
17
+
18
+ **Architecture:**
19
+
20
+ ```mermaid
21
+ graph TD
22
+ A[Development Container<br/>Your application code<br/>redis-cli client<br/>Connects to redis:6379] -->|Docker network devnet| B[Redis Container<br/>Redis 7 server<br/>Port 6379<br/>Data volume optional]
23
+ ```
24
+
25
+ ## Configuration
26
+
27
+ ### Environment Variables
28
+
29
+ The overlay includes a `.env.example` file. Copy it to `.env` and customize:
30
+
31
+ ```bash
32
+ cd .devcontainer
33
+ cp .env.example .env
34
+ ```
35
+
36
+ **Default values (.env.example):**
37
+
38
+ ```bash
39
+ # Redis Configuration
40
+ REDIS_PORT=6379
41
+ REDIS_PASSWORD=
42
+ ```
43
+
44
+ ⚠️ **Note:** Redis runs without password by default for development. Set `REDIS_PASSWORD` for production-like environments.
45
+
46
+ ### Port Configuration
47
+
48
+ The default port (6379) can be changed via the `--port-offset` option:
49
+
50
+ ```bash
51
+ # Offset all ports by 100
52
+ container-superposition --port-offset 100
53
+
54
+ # Redis will be on 6479 instead of 6379
55
+ ```
56
+
57
+ ## Connection Information
58
+
59
+ ### From Development Container
60
+
61
+ ```bash
62
+ # Hostname: redis (Docker Compose service name)
63
+ # Port: 6379
64
+ # Password: (empty by default, or value from .env)
65
+
66
+ # Connection string (no password)
67
+ redis://redis:6379
68
+
69
+ # Connection string (with password)
70
+ redis://:password@redis:6379
71
+ ```
72
+
73
+ ### From Host Machine
74
+
75
+ ```bash
76
+ # Hostname: localhost
77
+ # Port: 6379 (or 6379 + port-offset)
78
+ # Password: (empty or value from .env)
79
+
80
+ # Connection string
81
+ redis://localhost:6379
82
+ ```
83
+
84
+ ## Common Commands
85
+
86
+ ### Using redis-cli
87
+
88
+ The Redis CLI is pre-installed in your development container.
89
+
90
+ ```bash
91
+ # Connect to Redis
92
+ redis-cli -h redis
93
+
94
+ # Connect with password
95
+ redis-cli -h redis -a password
96
+
97
+ # Execute single command
98
+ redis-cli -h redis PING
99
+
100
+ # Execute from stdin
101
+ echo "SET mykey myvalue" | redis-cli -h redis
102
+
103
+ # Execute commands from file
104
+ redis-cli -h redis < commands.txt
105
+ ```
106
+
107
+ ### Basic Operations
108
+
109
+ ```bash
110
+ # Test connection
111
+ PING
112
+ # Response: PONG
113
+
114
+ # Set key-value
115
+ SET mykey "Hello Redis"
116
+
117
+ # Get value
118
+ GET mykey
119
+
120
+ # Set with expiration (seconds)
121
+ SETEX session:123 3600 "user_data"
122
+
123
+ # Set if not exists
124
+ SETNX mykey "value"
125
+
126
+ # Delete key
127
+ DEL mykey
128
+
129
+ # Check if key exists
130
+ EXISTS mykey
131
+
132
+ # Get key type
133
+ TYPE mykey
134
+
135
+ # Set expiration
136
+ EXPIRE mykey 60
137
+
138
+ # Get time to live
139
+ TTL mykey
140
+
141
+ # Rename key
142
+ RENAME oldkey newkey
143
+
144
+ # Get all keys (⚠️ don't use in production with many keys)
145
+ KEYS *
146
+
147
+ # Scan keys (better for production)
148
+ SCAN 0 MATCH user:* COUNT 100
149
+ ```
150
+
151
+ ### Data Types
152
+
153
+ #### Strings
154
+
155
+ ```bash
156
+ # Set string
157
+ SET user:1:name "John Doe"
158
+
159
+ # Get string
160
+ GET user:1:name
161
+
162
+ # Increment
163
+ SET counter 0
164
+ INCR counter
165
+ INCRBY counter 10
166
+
167
+ # Append
168
+ APPEND user:1:name " Jr."
169
+
170
+ # Get string length
171
+ STRLEN user:1:name
172
+
173
+ # Multiple set/get
174
+ MSET key1 "value1" key2 "value2" key3 "value3"
175
+ MGET key1 key2 key3
176
+ ```
177
+
178
+ #### Lists
179
+
180
+ ```bash
181
+ # Push to list (right)
182
+ RPUSH mylist "item1" "item2" "item3"
183
+
184
+ # Push to list (left)
185
+ LPUSH mylist "item0"
186
+
187
+ # Get range
188
+ LRANGE mylist 0 -1
189
+
190
+ # Pop from list (right)
191
+ RPOP mylist
192
+
193
+ # Pop from list (left)
194
+ LPOP mylist
195
+
196
+ # Get length
197
+ LLEN mylist
198
+
199
+ # Get by index
200
+ LINDEX mylist 0
201
+
202
+ # Trim list
203
+ LTRIM mylist 0 99
204
+ ```
205
+
206
+ #### Sets
207
+
208
+ ```bash
209
+ # Add members
210
+ SADD myset "member1" "member2" "member3"
211
+
212
+ # Get all members
213
+ SMEMBERS myset
214
+
215
+ # Check membership
216
+ SISMEMBER myset "member1"
217
+
218
+ # Remove member
219
+ SREM myset "member1"
220
+
221
+ # Get set size
222
+ SCARD myset
223
+
224
+ # Set operations
225
+ SADD set1 "a" "b" "c"
226
+ SADD set2 "b" "c" "d"
227
+ SINTER set1 set2 # Intersection
228
+ SUNION set1 set2 # Union
229
+ SDIFF set1 set2 # Difference
230
+
231
+ # Random member
232
+ SRANDMEMBER myset
233
+
234
+ # Pop random member
235
+ SPOP myset
236
+ ```
237
+
238
+ #### Sorted Sets
239
+
240
+ ```bash
241
+ # Add members with scores
242
+ ZADD leaderboard 100 "player1" 200 "player2" 150 "player3"
243
+
244
+ # Get range by rank
245
+ ZRANGE leaderboard 0 -1
246
+
247
+ # Get range with scores
248
+ ZRANGE leaderboard 0 -1 WITHSCORES
249
+
250
+ # Get range by score
251
+ ZRANGEBYSCORE leaderboard 100 200
252
+
253
+ # Get rank
254
+ ZRANK leaderboard "player1"
255
+
256
+ # Get score
257
+ ZSCORE leaderboard "player1"
258
+
259
+ # Increment score
260
+ ZINCRBY leaderboard 50 "player1"
261
+
262
+ # Remove member
263
+ ZREM leaderboard "player1"
264
+
265
+ # Get size
266
+ ZCARD leaderboard
267
+
268
+ # Count by score range
269
+ ZCOUNT leaderboard 100 200
270
+ ```
271
+
272
+ #### Hashes
273
+
274
+ ```bash
275
+ # Set hash field
276
+ HSET user:1 name "John" email "john@example.com" age 30
277
+
278
+ # Get hash field
279
+ HGET user:1 name
280
+
281
+ # Get all hash fields
282
+ HGETALL user:1
283
+
284
+ # Get multiple fields
285
+ HMGET user:1 name email
286
+
287
+ # Delete field
288
+ HDEL user:1 age
289
+
290
+ # Check field exists
291
+ HEXISTS user:1 name
292
+
293
+ # Get all keys
294
+ HKEYS user:1
295
+
296
+ # Get all values
297
+ HVALS user:1
298
+
299
+ # Get field count
300
+ HLEN user:1
301
+
302
+ # Increment field
303
+ HINCRBY user:1 age 1
304
+ ```
305
+
306
+ ### Advanced Operations
307
+
308
+ #### Transactions
309
+
310
+ ```bash
311
+ # Begin transaction
312
+ MULTI
313
+
314
+ # Queue commands
315
+ SET key1 "value1"
316
+ SET key2 "value2"
317
+ INCR counter
318
+
319
+ # Execute transaction
320
+ EXEC
321
+
322
+ # Discard transaction
323
+ DISCARD
324
+ ```
325
+
326
+ #### Pub/Sub
327
+
328
+ ```bash
329
+ # Subscribe to channel (in one redis-cli session)
330
+ SUBSCRIBE mychannel
331
+
332
+ # Publish message (in another redis-cli session)
333
+ PUBLISH mychannel "Hello subscribers!"
334
+
335
+ # Pattern subscription
336
+ PSUBSCRIBE news:*
337
+
338
+ # Unsubscribe
339
+ UNSUBSCRIBE mychannel
340
+ ```
341
+
342
+ #### Pipelining
343
+
344
+ ```bash
345
+ # Multiple commands in one request (from shell)
346
+ (echo "SET key1 value1"; echo "GET key1"; echo "INCR counter") | redis-cli -h redis
347
+ ```
348
+
349
+ ### Database Management
350
+
351
+ ```bash
352
+ # Select database (0-15 by default)
353
+ SELECT 1
354
+
355
+ # Flush current database
356
+ FLUSHDB
357
+
358
+ # Flush all databases (⚠️ destructive)
359
+ FLUSHALL
360
+
361
+ # Get database size
362
+ DBSIZE
363
+
364
+ # Save to disk (blocking)
365
+ SAVE
366
+
367
+ # Save to disk (non-blocking)
368
+ BGSAVE
369
+
370
+ # Get server info
371
+ INFO
372
+
373
+ # Get specific info section
374
+ INFO stats
375
+ INFO memory
376
+ INFO replication
377
+
378
+ # Monitor commands in real-time
379
+ MONITOR
380
+
381
+ # Get configuration
382
+ CONFIG GET maxmemory
383
+ CONFIG GET *
384
+
385
+ # Set configuration (runtime)
386
+ CONFIG SET maxmemory 256mb
387
+
388
+ # Last save time
389
+ LASTSAVE
390
+ ```
391
+
392
+ ## Application Integration
393
+
394
+ ### Node.js (ioredis)
395
+
396
+ ```bash
397
+ npm install ioredis
398
+ ```
399
+
400
+ ```javascript
401
+ const Redis = require('ioredis');
402
+
403
+ const redis = new Redis({
404
+ host: 'redis',
405
+ port: 6379,
406
+ // password: 'your-password', // if configured
407
+ });
408
+
409
+ // Set and get
410
+ await redis.set('key', 'value');
411
+ const value = await redis.get('key');
412
+
413
+ // Set with expiration
414
+ await redis.setex('session:123', 3600, 'user_data');
415
+
416
+ // Hash operations
417
+ await redis.hset('user:1', 'name', 'John', 'email', 'john@example.com');
418
+ const user = await redis.hgetall('user:1');
419
+
420
+ // List operations
421
+ await redis.rpush('queue', 'job1', 'job2');
422
+ const job = await redis.lpop('queue');
423
+
424
+ // Pub/Sub
425
+ redis.subscribe('notifications', (err, count) => {
426
+ console.log(`Subscribed to ${count} channel(s)`);
427
+ });
428
+
429
+ redis.on('message', (channel, message) => {
430
+ console.log(`Received: ${message} from ${channel}`);
431
+ });
432
+ ```
433
+
434
+ ### Python (redis-py)
435
+
436
+ ```bash
437
+ pip install redis
438
+ ```
439
+
440
+ ```python
441
+ import redis
442
+
443
+ r = redis.Redis(
444
+ host='redis',
445
+ port=6379,
446
+ decode_responses=True,
447
+ # password='your-password', # if configured
448
+ )
449
+
450
+ # Set and get
451
+ r.set('key', 'value')
452
+ value = r.get('key')
453
+
454
+ # Set with expiration
455
+ r.setex('session:123', 3600, 'user_data')
456
+
457
+ # Hash operations
458
+ r.hset('user:1', mapping={'name': 'John', 'email': 'john@example.com'})
459
+ user = r.hgetall('user:1')
460
+
461
+ # List operations
462
+ r.rpush('queue', 'job1', 'job2')
463
+ job = r.lpop('queue')
464
+
465
+ # Pub/Sub
466
+ pubsub = r.pubsub()
467
+ pubsub.subscribe('notifications')
468
+
469
+ for message in pubsub.listen():
470
+ print(f"Received: {message}")
471
+ ```
472
+
473
+ ### .NET (StackExchange.Redis)
474
+
475
+ ```bash
476
+ dotnet add package StackExchange.Redis
477
+ ```
478
+
479
+ ```csharp
480
+ using StackExchange.Redis;
481
+
482
+ var redis = ConnectionMultiplexer.Connect("redis:6379");
483
+ var db = redis.GetDatabase();
484
+
485
+ // Set and get
486
+ await db.StringSetAsync("key", "value");
487
+ var value = await db.StringGetAsync("key");
488
+
489
+ // Set with expiration
490
+ await db.StringSetAsync("session:123", "user_data", TimeSpan.FromHours(1));
491
+
492
+ // Hash operations
493
+ await db.HashSetAsync("user:1", new HashEntry[] {
494
+ new HashEntry("name", "John"),
495
+ new HashEntry("email", "john@example.com")
496
+ });
497
+ var user = await db.HashGetAllAsync("user:1");
498
+
499
+ // List operations
500
+ await db.ListRightPushAsync("queue", "job1");
501
+ var job = await db.ListLeftPopAsync("queue");
502
+
503
+ // Pub/Sub
504
+ var subscriber = redis.GetSubscriber();
505
+ await subscriber.SubscribeAsync("notifications", (channel, message) => {
506
+ Console.WriteLine($"Received: {message}");
507
+ });
508
+ ```
509
+
510
+ ### Go (go-redis)
511
+
512
+ ```bash
513
+ go get github.com/redis/go-redis/v9
514
+ ```
515
+
516
+ ```go
517
+ package main
518
+
519
+ import (
520
+ "context"
521
+ "github.com/redis/go-redis/v9"
522
+ "time"
523
+ )
524
+
525
+ func main() {
526
+ ctx := context.Background()
527
+
528
+ rdb := redis.NewClient(&redis.Options{
529
+ Addr: "redis:6379",
530
+ // Password: "your-password", // if configured
531
+ DB: 0,
532
+ })
533
+
534
+ // Set and get
535
+ rdb.Set(ctx, "key", "value", 0)
536
+ val, _ := rdb.Get(ctx, "key").Result()
537
+
538
+ // Set with expiration
539
+ rdb.Set(ctx, "session:123", "user_data", time.Hour)
540
+
541
+ // Hash operations
542
+ rdb.HSet(ctx, "user:1", "name", "John", "email", "john@example.com")
543
+ user, _ := rdb.HGetAll(ctx, "user:1").Result()
544
+
545
+ // List operations
546
+ rdb.RPush(ctx, "queue", "job1", "job2")
547
+ job, _ := rdb.LPop(ctx, "queue").Result()
548
+
549
+ // Pub/Sub
550
+ pubsub := rdb.Subscribe(ctx, "notifications")
551
+ ch := pubsub.Channel()
552
+
553
+ for msg := range ch {
554
+ println("Received:", msg.Payload)
555
+ }
556
+ }
557
+ ```
558
+
559
+ ## Use Cases
560
+
561
+ ### Caching
562
+
563
+ - Page caching
564
+ - API response caching
565
+ - Database query caching
566
+ - Computed result caching
567
+
568
+ ### Session Management
569
+
570
+ - User session storage
571
+ - JWT token storage
572
+ - Shopping cart data
573
+ - Temporary user data
574
+
575
+ ### Real-time Features
576
+
577
+ - Live notifications via Pub/Sub
578
+ - Real-time analytics
579
+ - Message queues
580
+ - Chat applications
581
+
582
+ ### Rate Limiting
583
+
584
+ - API rate limiting
585
+ - Login attempt tracking
586
+ - Request throttling
587
+
588
+ ### Leaderboards and Counters
589
+
590
+ - Gaming leaderboards
591
+ - Analytics counters
592
+ - Social media likes/views
593
+ - Real-time statistics
594
+
595
+ ## Persistence Options
596
+
597
+ ### RDB (Redis Database Backup)
598
+
599
+ Periodic snapshots to disk:
600
+
601
+ ```bash
602
+ # Save now
603
+ SAVE # blocking
604
+ BGSAVE # non-blocking
605
+
606
+ # Configure automatic snapshots
607
+ # Add to redis.conf:
608
+ save 900 1 # Save after 900 sec if at least 1 key changed
609
+ save 300 10 # Save after 300 sec if at least 10 keys changed
610
+ save 60 10000 # Save after 60 sec if at least 10000 keys changed
611
+ ```
612
+
613
+ ### AOF (Append Only File)
614
+
615
+ Log every write operation:
616
+
617
+ ```bash
618
+ # Enable AOF (add to redis.conf)
619
+ appendonly yes
620
+ appendfilename "appendonly.aof"
621
+
622
+ # Sync strategy
623
+ appendfsync everysec # Good balance
624
+ # appendfsync always # Slower, safest
625
+ # appendfsync no # Fastest, less safe
626
+ ```
627
+
628
+ ## Monitoring and Debugging
629
+
630
+ ```bash
631
+ # Real-time monitoring
632
+ MONITOR
633
+
634
+ # Get server statistics
635
+ INFO stats
636
+ INFO memory
637
+ INFO cpu
638
+ INFO clients
639
+
640
+ # Slow query log
641
+ SLOWLOG GET 10
642
+
643
+ # Client list
644
+ CLIENT LIST
645
+
646
+ # Memory usage of key
647
+ MEMORY USAGE mykey
648
+
649
+ # Memory stats
650
+ MEMORY STATS
651
+ ```
652
+
653
+ ## Troubleshooting
654
+
655
+ ### Cannot connect to Redis
656
+
657
+ ```bash
658
+ # Check if Redis container is running
659
+ docker-compose ps
660
+
661
+ # Check Redis logs
662
+ docker-compose logs redis
663
+
664
+ # Test connection
665
+ redis-cli -h redis PING
666
+
667
+ # Check network connectivity
668
+ ping redis
669
+ ```
670
+
671
+ ### Authentication errors
672
+
673
+ ```bash
674
+ # If password is set, use -a flag
675
+ redis-cli -h redis -a your-password PING
676
+
677
+ # Or use AUTH command
678
+ redis-cli -h redis
679
+ AUTH your-password
680
+ PING
681
+ ```
682
+
683
+ ### Out of memory
684
+
685
+ ```bash
686
+ # Check memory usage
687
+ redis-cli -h redis INFO memory
688
+
689
+ # Check maxmemory setting
690
+ redis-cli -h redis CONFIG GET maxmemory
691
+
692
+ # Set maxmemory policy
693
+ redis-cli -h redis CONFIG SET maxmemory-policy allkeys-lru
694
+ ```
695
+
696
+ ### Data not persisting
697
+
698
+ ```bash
699
+ # Check if persistence is enabled
700
+ redis-cli -h redis CONFIG GET save
701
+
702
+ # Manually save
703
+ redis-cli -h redis BGSAVE
704
+
705
+ # Check last save time
706
+ redis-cli -h redis LASTSAVE
707
+ ```
708
+
709
+ ## Performance Tuning
710
+
711
+ ### Memory Optimization
712
+
713
+ ```bash
714
+ # Set eviction policy
715
+ CONFIG SET maxmemory-policy allkeys-lru
716
+
717
+ # Policies:
718
+ # - noeviction: Return error when memory limit reached
719
+ # - allkeys-lru: Evict least recently used keys
720
+ # - allkeys-lfu: Evict least frequently used keys
721
+ # - volatile-lru: Evict LRU keys with expire set
722
+ # - volatile-lfu: Evict LFU keys with expire set
723
+ # - volatile-ttl: Evict keys with shortest TTL
724
+ # - volatile-random: Evict random keys with expire set
725
+ # - allkeys-random: Evict random keys
726
+ ```
727
+
728
+ ### Connection Pooling
729
+
730
+ Always use connection pooling in production applications to reuse connections and reduce overhead.
731
+
732
+ ## Best Practices
733
+
734
+ 1. **Use appropriate data structures** - Choose the right Redis data type for your use case
735
+ 2. **Set expiration times** - Use TTL to automatically clean up old data
736
+ 3. **Use pipelining** - Batch commands for better performance
737
+ 4. **Avoid KEYS in production** - Use SCAN instead for large datasets
738
+ 5. **Monitor memory usage** - Set maxmemory and eviction policies
739
+ 6. **Use connection pooling** - Reuse connections in applications
740
+ 7. **Enable persistence** - Use RDB or AOF for data durability
741
+ 8. **Secure with password** - Set REDIS_PASSWORD for production
742
+ 9. **Use transactions** - Use MULTI/EXEC for atomic operations
743
+ 10. **Regular backups** - Backup RDB/AOF files regularly
744
+
745
+ ## Security Considerations
746
+
747
+ 1. **Set password** - Configure REDIS_PASSWORD in production
748
+ 2. **Bind to localhost** - Don't expose Redis to public internet
749
+ 3. **Use firewall** - Restrict access to trusted IP addresses
750
+ 4. **Disable dangerous commands** - Rename or disable FLUSHALL, FLUSHDB, CONFIG
751
+ 5. **Regular updates** - Keep Redis updated for security patches
752
+ 6. **Use TLS** - Enable TLS encryption for sensitive data
753
+
754
+ ## Related Overlays
755
+
756
+ - **nodejs** - For Node.js applications with Redis
757
+ - **python** - For Python applications (Django, Flask, Celery)
758
+ - **dotnet** - For .NET applications with StackExchange.Redis
759
+ - **postgres** - Often used together (Redis for cache, PostgreSQL for data)
760
+ - **prometheus** - For Redis monitoring with redis_exporter
761
+
762
+ ## Additional Resources
763
+
764
+ - [Redis Documentation](https://redis.io/docs/)
765
+ - [Redis Commands Reference](https://redis.io/commands/)
766
+ - [Redis Best Practices](https://redis.io/docs/manual/patterns/)
767
+ - [Redis Data Types](https://redis.io/docs/manual/data-types/)
768
+ - [Redis Persistence](https://redis.io/docs/manual/persistence/)
769
+
770
+ ## Notes
771
+
772
+ - This overlay **requires compose stack** (uses docker-compose)
773
+ - Redis runs on port **6379** (configurable with port-offset)
774
+ - Data persistence is **optional** (configure RDB/AOF as needed)
775
+ - Use hostname **`redis`** from development container
776
+ - Use **`localhost`** from host machine