[backend] Remove cache server configuration, migrate back to unified redis in-memory cache

This commit is contained in:
Laura Hausmann 2023-11-05 15:00:19 +01:00
parent 9d4f74d290
commit 42aa8b7126
Signed by: zotan
GPG key ID: D044E84C5BE01605
9 changed files with 5 additions and 91 deletions

View file

@ -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.

View file

@ -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.

View file

@ -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

View file

@ -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:

View file

@ -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

View file

@ -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);
}

View file

@ -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;

View file

@ -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,

View file

@ -38,7 +38,7 @@ export class Cache<T> {
}
public async getAll(renew = false): Promise<Map<string, T>> {
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<string, T>();