Skip to content

Commit c8c3b48

Browse files
authored
Merge pull request #343 from FoxxMD/caching
feat: Caching and persistent scrobble queues
2 parents 70bb304 + 0a673fd commit c8c3b48

File tree

24 files changed

+1201
-106
lines changed

24 files changed

+1201
-106
lines changed

.devcontainer/compose.yml

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
version: '3.7'
2+
services:
3+
# Update this to the name of the service you want to work with in your docker-compose.yml file
4+
app:
5+
# Uncomment if you want to override the service's Dockerfile to one in the .devcontainer
6+
# folder. Note that the path of the Dockerfile and context is relative to the *primary*
7+
# docker-compose.yml file (the first in the devcontainer.json "dockerComposeFile"
8+
# array). The sample below assumes your primary file is in the root of your project.
9+
#
10+
# build:
11+
# context: .
12+
# dockerfile: .devcontainer/Dockerfile
13+
14+
image: mcr.microsoft.com/devcontainers/javascript-node:1-20-bookworm
15+
16+
volumes:
17+
# Update this to wherever you want VS Code to mount the folder of your project
18+
- ..:/workspaces:cached
19+
command: sleep infinity
20+
21+
valkey:
22+
image: valkey/valkey
23+
env_file:
24+
- path: ./.env
25+
required: false

.devcontainer/devcontainer.json

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,13 @@
33
{
44
"name": "Node.js",
55
// Or use a Dockerfile or Docker Compose file. More info: https://containers.dev/guide/dockerfile
6-
"image": "mcr.microsoft.com/devcontainers/javascript-node:1-20-bookworm",
6+
"dockerComposeFile": [
7+
"compose.yml"
8+
],
9+
10+
"service": "app",
11+
12+
"workspaceFolder": "/workspaces",
713

814
// Features to add to the dev container. More info: https://containers.dev/features.
915
// "features": {},

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,9 @@ dist
118118
.pnp.*
119119

120120
config/*.json
121+
config/mscache
121122
config/yti-*
123+
config/*.cache
122124
*.txt
123125
.idea/
124126

.mocharc.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,8 @@
33
"extension": "ts",
44
"import": "tsx/esm",
55
"spec": "./src/backend/tests/**/*.test.ts",
6+
"file": [
7+
"./src/backend/tests/setup.ts"
8+
],
69
"exit": true
710
}

docsite/docs/configuration/configuration.mdx

Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,93 @@ Useful when running with [docker](../installation/installation.mdx#docker) so th
186186

187187
</details>
188188

189+
#### Caching
190+
191+
Multi-scrobbler can cache some of its data for the purpose of **persisting queued and dead scrobbles** after restarting.
192+
193+
It supports caching using either:
194+
195+
* **File** cache stored in the `CONFIG_DIR` directory (next to your File/[AIO](./?configType=aio#configuration-types) file)
196+
* [**Valkey**](https://valkey.io/), an open-source fork of Redis.
197+
198+
**File** caching is **enabled by default** when no other configuration is present.
199+
200+
The type of cache used, and it's connection properties, can be configured through ENV or **AIO** config.
201+
202+
##### Caching Configuration
203+
204+
<Tabs groupId="cache" queryString>
205+
206+
<TabItem value="file" label="File">
207+
208+
**File** cache is stored in the `CONFIG_DIR` directory using the pre-defined file name `ms-scrobble.cache`.
209+
210+
It is **enabled by default** if `CACHE_SCROBBLE`, or the respective AIO configuration, is not defined.
211+
212+
<Tabs groupId="configType" queryString>
213+
214+
<TabItem value="env" label="ENV">
215+
216+
| Environmental Variable | Required? | Default | Description |
217+
| :--------------------- | --------- | -------------------- | ------------------------------------------------------------ |
218+
| `CACHE_SCROBBLE` | No | `file` | The cache type to use |
219+
| `CACHE_SCROBBLE_CONN` | No | The config directory | The directory, within the container, to store the cache file |
220+
221+
</TabItem>
222+
223+
<TabItem value="aio" label="AIO">
224+
225+
```json5 title="config.json"
226+
{
227+
"cache": {
228+
"scrobble": {
229+
"provider": "file",
230+
"connection": "/config"
231+
}
232+
},
233+
// ...
234+
}
235+
```
236+
237+
</TabItem>
238+
239+
</Tabs>
240+
</TabItem>
241+
242+
<TabItem value="valkey" label="Valkey">
243+
244+
<Tabs groupId="configType" queryString>
245+
246+
<TabItem value="env" label="ENV">
247+
248+
| Environmental Variable | Required? | Default | Description |
249+
| :--------------------- | --------- | -------------------- | ------------------------------------------------------------ |
250+
| `CACHE_SCROBBLE` | Yes | `valkey` | The cache type to use |
251+
| `CACHE_SCROBBLE_CONN` | Yes | | The host/IP and port to connect to, prefixed with `redis://` -- EX: `redis://192.168.0.120:6379` |
252+
253+
</TabItem>
254+
255+
<TabItem value="aio" label="AIO">
256+
257+
```json5 title="config.json"
258+
{
259+
"cache": {
260+
"scrobble": {
261+
"provider": "valkey",
262+
"connection": "redis://192.168.0.120:6379"
263+
}
264+
},
265+
// ...
266+
}
267+
```
268+
269+
</TabItem>
270+
271+
</Tabs>
272+
</TabItem>
273+
274+
</Tabs>
275+
189276
#### Debug Mode
190277

191278
Turning on Debug Mode will

0 commit comments

Comments
 (0)