From 42aa8b712695f68887243b577bcf09858c833c18 Mon Sep 17 00:00:00 2001 From: Laura Hausmann Date: Sun, 5 Nov 2023 15:00:19 +0100 Subject: [PATCH] [backend] Remove cache server configuration, migrate back to unified redis in-memory cache --- .config/example-docker.yml | 15 ----------- .config/example.yml | 14 ---------- docs/docker-compose-install.md | 4 +-- docs/examples/docker-compose.yml | 38 ---------------------------- docs/install.md | 7 +---- packages/backend/src/config/load.ts | 2 -- packages/backend/src/config/types.ts | 10 -------- packages/backend/src/db/redis.ts | 4 +-- packages/backend/src/misc/cache.ts | 2 +- 9 files changed, 5 insertions(+), 91 deletions(-) diff --git a/.config/example-docker.yml b/.config/example-docker.yml index b80e809a2..09a481bd3 100644 --- a/.config/example-docker.yml +++ b/.config/example-docker.yml @@ -72,21 +72,6 @@ redis: #db: 1 #user: default -# ┌────────────────────────────┐ -#───┘ Cache server configuration └────────────────────────────── - -# A Redis-compatible server (DragonflyDB, Keydb, Redis) for caching -# If left blank, it will use the Redis server from above -# Possible values for host: dragonflydb, keydb, redis_cache - -#cacheServer: - #host: - #port: 6379 - ##family: 0 # 0=Both, 4=IPv4, 6=IPv6 - ##pass: example-pass - ##prefix: example-prefix - ##db: 1 - # Please configure either MeiliSearch *or* Sonic. # If both MeiliSearch and Sonic configurations are present, MeiliSearch will take precedence. diff --git a/.config/example.yml b/.config/example.yml index 7fd3e5812..d2cd97ba5 100644 --- a/.config/example.yml +++ b/.config/example.yml @@ -72,20 +72,6 @@ redis: #db: 1 #user: default -# ┌────────────────────────────┐ -#───┘ Cache server configuration └────────────────────────────── - -# A Redis-compatible server (DragonflyDB, Keydb, Redis) for caching -# If left blank, it will use the Redis server from above - -#cacheServer: - #host: localhost - #port: 6379 - #family: 0 # 0=Both, 4=IPv4, 6=IPv6 - #pass: example-pass - #prefix: example-prefix - #db: 1 - # Please configure either MeiliSearch *or* Sonic. # If both MeiliSearch and Sonic configurations are present, MeiliSearch will take precedence. diff --git a/docs/docker-compose-install.md b/docs/docker-compose-install.md index 28d2f902a..79648e941 100644 --- a/docs/docker-compose-install.md +++ b/docs/docker-compose-install.md @@ -12,7 +12,7 @@ Run `git clone https://iceshrimp.dev/iceshrimp/iceshrimp`, but if you are not pl First, run `cp docs/examples/docker-compose.yml docker-compose.yml`, and edit `docker-compose.yml` if - you want to build the image yourself or choose a [different tag](https://iceshrimp.dev/iceshrimp/-/packages/container/iceshrimp/versions), and/or -- you want a search engine for better search performance and/or a cache server for better antenna handling. +- you want a search engine for better search performance. ### .config @@ -20,7 +20,7 @@ Run `cp .config/docker_example.env .config/docker.env`, and edit `.config/docker Run `cp .config/example-docker.yml .config/default.yml`, and edit `.config/default.yml` - Replace example database credentials with the ones you entered in `.config/docker.env` - Change other configuration -- Optionally, set up the search engine and cache server, if you have chosen to set them up. +- Optionally, set up the search backend, if you have chosen to set one up. ## Installation and first start diff --git a/docs/examples/docker-compose.yml b/docs/examples/docker-compose.yml index 812f6c8bb..240544c56 100644 --- a/docs/examples/docker-compose.yml +++ b/docs/examples/docker-compose.yml @@ -18,10 +18,6 @@ services: ### Uncomment one of the following to use a search engine # - meilisearch # - sonic -### Uncomment one of the following to use a cache server -# - dragonflydb -# - keydb -# - redis_cache ports: - "3000:3000" networks: @@ -80,40 +76,6 @@ services: # - ./sonic:/var/lib/sonic/store # - ./sonic/config.cfg:/etc/sonic.cfg -### Cache Servers -### Only one of the below should be used. -### DragonflyDB is the fastest overall, however it is NOT open source, but source-available (BSL). KeyDB is still faster than pure Redis, and it's BSD-licensed. -# dragonflydb: -# container_name: iceshrimp_dragonflydb -# restart: unless-stopped -# image: 'docker.dragonflydb.io/dragonflydb/dragonfly:v1.8.0' -# ulimits: -# memlock: -1 -# networks: -# - ishnet -# volumes: -# - ./dragonflydb:/data - -# keydb: -# container_name: iceshrimp_keydb -# restart: unless-stopped -### Choose an image depending on your architecture, keydb doesn't build alpine for arm, and the way they do tags is very weird in general -## image: 'docker.io/eqalpha/keydb:alpine_x86_64_v6.3.3' -## image: 'docker.io/eqalpha/keydb:arm64_v6.3.3' -# networks: -# - ishnet -# volumes: -# - ./keydb:/data - -# redis_cache: -# restart: unless-stopped -# image: docker.io/redis:7.0-alpine -# container_name: iceshrimp_redis_cache -# networks: -# - ishnet -# volumes: -# - ./redis_cache:/data - networks: ishnet: # web: diff --git a/docs/install.md b/docs/install.md index f37cfba5e..1feb0a53a 100644 --- a/docs/install.md +++ b/docs/install.md @@ -27,11 +27,6 @@ This document will guide you through manual installation of Iceshrimp on dev bra Iceshrimp has full text search powered by Postgres by default, however it's very slow, and these are alternatives for that - [**Meilisearch**](https://www.meilisearch.com/) | [Installation guide](https://www.meilisearch.com/docs/learn/getting_started/quick_start) - [**Sonic**](https://crates.io/crates/sonic-server) (More lightweight, but less features) | [Installation guide](https://github.com/valeriansaliou/sonic#installation) -- Caching server (Choose one) - This will be used for storing stuff like antennas. If you won't install any, mandatory Redis instance will be used instead - - [**DragonflyDB**](https://www.dragonflydb.io/) | [Installation guide](https://www.dragonflydb.io/docs/getting-started) - - [**KeyDB**](https://docs.keydb.dev/) | [Installation guide](https://docs.keydb.dev/docs/open-source-getting-started) - - Another **Redis** server ## Preparations @@ -51,7 +46,7 @@ Following steps will require you to run them as the user you have made, so use ` - Copy `.config/example.yml` to `.config/default.yml` - Edit `.config/default.yml` with text editor - Make sure to set PostgreSQL and Redis section correctly - - Make sure to set/uncomment caching server and/or text search sections if you have chosen to set up these + - Make sure to set/uncomment text search sections if you have chosen to set up a search backend ## Installing project dependencies diff --git a/packages/backend/src/config/load.ts b/packages/backend/src/config/load.ts index ebbec34d0..d2b6d3a88 100644 --- a/packages/backend/src/config/load.ts +++ b/packages/backend/src/config/load.ts @@ -65,8 +65,6 @@ export default function load() { mixin.clientEntry = clientManifest["src/init.ts"]; if (!config.redis.prefix) config.redis.prefix = mixin.hostname; - if (config.cacheServer && !config.cacheServer.prefix) - config.cacheServer.prefix = mixin.hostname; return Object.assign(config, mixin); } diff --git a/packages/backend/src/config/types.ts b/packages/backend/src/config/types.ts index 2b8fa5a71..40e8192dd 100644 --- a/packages/backend/src/config/types.ts +++ b/packages/backend/src/config/types.ts @@ -27,16 +27,6 @@ export type Source = { user?: string; tls?: { [y: string]: string }; }; - cacheServer?: { - host: string; - port: number; - family?: number; - pass?: string; - db?: number; - prefix?: string; - user?: string; - tls?: { [z: string]: string }; - }; elasticsearch: { host: string; port: number; diff --git a/packages/backend/src/db/redis.ts b/packages/backend/src/db/redis.ts index 215effd8e..b07adcb50 100644 --- a/packages/backend/src/db/redis.ts +++ b/packages/backend/src/db/redis.ts @@ -3,9 +3,7 @@ import config from "@/config/index.js"; export function createConnection() { let source = config.redis; - if (config.cacheServer) { - source = config.cacheServer; - } + return new Redis({ port: source.port, host: source.host, diff --git a/packages/backend/src/misc/cache.ts b/packages/backend/src/misc/cache.ts index c9cac7394..f4e7a07fb 100644 --- a/packages/backend/src/misc/cache.ts +++ b/packages/backend/src/misc/cache.ts @@ -38,7 +38,7 @@ export class Cache { } public async getAll(renew = false): Promise> { - const finalPrefix = `${config.cacheServer?.prefix ?? config.redis.prefix}:${this.prefix}:`; + const finalPrefix = `${config.redis.prefix}:${this.prefix}:`; const keys = (await redisClient.keys(`${finalPrefix}*`)).map(p => p.substring(finalPrefix.length)); const prefixedKeys = keys.map(p => this.prefixedKey(p)); const map = new Map();