blob: 9db86ddfc6a10f86210405b23e1cb8e7c2e01ef6 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
|
/*
This file is part of jellything (https://codeberg.org/metamuffin/jellything)
which is licensed under the GNU Affero General Public License (version 3); see /COPYING.
Copyright (C) 2026 metamuffin <metamuffin.org>
*/
use crate::{Config, backends::CacheStorage};
use anyhow::Result;
use rocksdb::DB;
pub struct Rocksdb(DB);
impl Rocksdb {
pub fn new(config: &Config) -> Result<Self> {
Ok(Self(rocksdb::DB::open_default(config.path.clone())?))
}
}
impl CacheStorage for Rocksdb {
fn store(&self, key: String, value: &[u8]) -> Result<()> {
Ok(self.0.put(key, value)?)
}
fn read(&self, key: &str) -> Result<Option<Vec<u8>>> {
Ok(self.0.get(key)?)
}
}
|