mirror of
https://iceshrimp.dev/crimekillz/iceshrimp-161sh.git
synced 2024-11-22 04:03:49 +01:00
feat: ⚡ cache server
This commit is contained in:
parent
53ec5f7048
commit
f5c7b6f55f
@ -67,6 +67,20 @@ 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.
|
||||
|
||||
|
@ -104,7 +104,10 @@ If you have access to a server that supports one of the sources below, I recomme
|
||||
- 🦔 [Sonic](https://crates.io/crates/sonic-server)
|
||||
- [MeiliSearch](https://www.meilisearch.com/)
|
||||
- [ElasticSearch](https://www.elastic.co/elasticsearch/)
|
||||
|
||||
- Caching server
|
||||
- 🐲 At least [Dragonfly](https://www.dragonflydb.io/) v1.4.0 (recommended)
|
||||
- 👻 [KeyDB](https://keydb.dev/) (untested)
|
||||
- 🍱 Another [Redis](https://redis.io/) server, at least v6
|
||||
### 🏗️ Build dependencies
|
||||
|
||||
- 🦀 At least [Rust](https://www.rust-lang.org/) v1.68.0
|
||||
@ -161,6 +164,10 @@ psql postgres -c "create database calckey with encoding = 'UTF8';"
|
||||
|
||||
In Calckey's directory, fill out the `db` section of `.config/default.yml` with the correct information, where the `db` key is `calckey`.
|
||||
|
||||
## 💰 Caching server
|
||||
|
||||
If you experience a lot of traffic, it's a good idea to set up another Redis-compatible caching server. If you don't set one one up, it'll falll back to the mandatory Redis server.
|
||||
|
||||
## 🔎 Set up search
|
||||
|
||||
### 🦔 Sonic
|
||||
|
@ -26,6 +26,16 @@ 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;
|
||||
|
@ -2,15 +2,19 @@ import Redis from "ioredis";
|
||||
import config from "@/config/index.js";
|
||||
|
||||
export function createConnection() {
|
||||
let source = config.redis;
|
||||
if (config.cacheServer) {
|
||||
source = config.cacheServer;
|
||||
}
|
||||
return new Redis({
|
||||
port: config.redis.port,
|
||||
host: config.redis.host,
|
||||
family: config.redis.family ?? 0,
|
||||
password: config.redis.pass,
|
||||
username: config.redis.user ?? "default",
|
||||
keyPrefix: `${config.redis.prefix}:`,
|
||||
db: config.redis.db || 0,
|
||||
tls: config.redis.tls,
|
||||
port: source.port,
|
||||
host: source.host,
|
||||
family: source.family ?? 0,
|
||||
password: source.pass,
|
||||
username: source.user ?? "default",
|
||||
keyPrefix: `${source.prefix}:`,
|
||||
db: source.db || 0,
|
||||
tls: source.tls,
|
||||
});
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user