mirror of
https://iceshrimp.dev/limepotato/jormungandr-bite.git
synced 2024-11-24 10:57:30 -07:00
[backend] Remove cache server configuration, migrate back to unified redis in-memory cache
This commit is contained in:
parent
9d4f74d290
commit
42aa8b7126
9 changed files with 5 additions and 91 deletions
|
@ -72,21 +72,6 @@ redis:
|
||||||
#db: 1
|
#db: 1
|
||||||
#user: default
|
#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.
|
# Please configure either MeiliSearch *or* Sonic.
|
||||||
# If both MeiliSearch and Sonic configurations are present, MeiliSearch will take precedence.
|
# If both MeiliSearch and Sonic configurations are present, MeiliSearch will take precedence.
|
||||||
|
|
||||||
|
|
|
@ -72,20 +72,6 @@ redis:
|
||||||
#db: 1
|
#db: 1
|
||||||
#user: default
|
#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.
|
# Please configure either MeiliSearch *or* Sonic.
|
||||||
# If both MeiliSearch and Sonic configurations are present, MeiliSearch will take precedence.
|
# If both MeiliSearch and Sonic configurations are present, MeiliSearch will take precedence.
|
||||||
|
|
||||||
|
|
|
@ -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
|
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 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
|
### .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`
|
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`
|
- Replace example database credentials with the ones you entered in `.config/docker.env`
|
||||||
- Change other configuration
|
- 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
|
## Installation and first start
|
||||||
|
|
||||||
|
|
|
@ -18,10 +18,6 @@ services:
|
||||||
### Uncomment one of the following to use a search engine
|
### Uncomment one of the following to use a search engine
|
||||||
# - meilisearch
|
# - meilisearch
|
||||||
# - sonic
|
# - sonic
|
||||||
### Uncomment one of the following to use a cache server
|
|
||||||
# - dragonflydb
|
|
||||||
# - keydb
|
|
||||||
# - redis_cache
|
|
||||||
ports:
|
ports:
|
||||||
- "3000:3000"
|
- "3000:3000"
|
||||||
networks:
|
networks:
|
||||||
|
@ -80,40 +76,6 @@ services:
|
||||||
# - ./sonic:/var/lib/sonic/store
|
# - ./sonic:/var/lib/sonic/store
|
||||||
# - ./sonic/config.cfg:/etc/sonic.cfg
|
# - ./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:
|
networks:
|
||||||
ishnet:
|
ishnet:
|
||||||
# web:
|
# web:
|
||||||
|
|
|
@ -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
|
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)
|
- [**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)
|
- [**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
|
## 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`
|
- Copy `.config/example.yml` to `.config/default.yml`
|
||||||
- Edit `.config/default.yml` with text editor
|
- Edit `.config/default.yml` with text editor
|
||||||
- Make sure to set PostgreSQL and Redis section correctly
|
- 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
|
## Installing project dependencies
|
||||||
|
|
||||||
|
|
|
@ -65,8 +65,6 @@ export default function load() {
|
||||||
mixin.clientEntry = clientManifest["src/init.ts"];
|
mixin.clientEntry = clientManifest["src/init.ts"];
|
||||||
|
|
||||||
if (!config.redis.prefix) config.redis.prefix = mixin.hostname;
|
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);
|
return Object.assign(config, mixin);
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,16 +27,6 @@ export type Source = {
|
||||||
user?: string;
|
user?: string;
|
||||||
tls?: { [y: string]: 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: {
|
elasticsearch: {
|
||||||
host: string;
|
host: string;
|
||||||
port: number;
|
port: number;
|
||||||
|
|
|
@ -3,9 +3,7 @@ import config from "@/config/index.js";
|
||||||
|
|
||||||
export function createConnection() {
|
export function createConnection() {
|
||||||
let source = config.redis;
|
let source = config.redis;
|
||||||
if (config.cacheServer) {
|
|
||||||
source = config.cacheServer;
|
|
||||||
}
|
|
||||||
return new Redis({
|
return new Redis({
|
||||||
port: source.port,
|
port: source.port,
|
||||||
host: source.host,
|
host: source.host,
|
||||||
|
|
|
@ -38,7 +38,7 @@ export class Cache<T> {
|
||||||
}
|
}
|
||||||
|
|
||||||
public async getAll(renew = false): Promise<Map<string, 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 keys = (await redisClient.keys(`${finalPrefix}*`)).map(p => p.substring(finalPrefix.length));
|
||||||
const prefixedKeys = keys.map(p => this.prefixedKey(p));
|
const prefixedKeys = keys.map(p => this.prefixedKey(p));
|
||||||
const map = new Map<string, T>();
|
const map = new Map<string, T>();
|
||||||
|
|
Loading…
Reference in a new issue