xkv

Crates.ioxkv
lib.rsxkv
version0.1.48
created_at2023-06-19 00:17:55.42339+00
updated_at2025-09-03 10:01:40.712858+00
descriptionuse global static vars connect redis with fred or kvrocks / 使用全局静态变量通过 fred 连接 redis 或 kvrocks
homepagehttps://github.com/i18n-site/rust/tree/main/xkv
repositoryhttps://github.com/i18n-site/rust.git
max_upload_size
id893693
size47,339
i18n.site (i18nsite)

documentation

README

xkv

use global static vars connect redis / kvrocks with fred

使用全局静态变量通过 fred 连接 redis / kvrocks

use aok::{OK, Result};
use xkv::{R, fred::interfaces::KeysInterface, log::info};

async fn test_redis() -> Result<()> {
  let key = "xkvtest1";
  let val = "abc";
  R!(del key);

  let v: bool = R.exists(key).await?;
  assert!(!v);

  let v: Option<String> = R.get(key).await?;
  info!("get {key} = {:?}", v);
  assert_eq!(v, None);

  R!(set key, val, None, None, false);

  let v: Option<String> = R.get(key).await?;
  info!("get {key} = {:?}", v);
  assert_eq!(v, Some(val.into()));

  R!(del key);

  OK
}

#[tokio::main]
async fn main() -> Result<()> {
  // 仅在程序启动的main函数中调用一次 / Call it only once in the main function of the program
  static_::init().await?;
  test_redis().await?;
  OK
}

About

This project is an open-source component of i18n.site ⋅ Internationalization Solution.

关于

本项目为 i18n.site ⋅ 国际化解决方案 的开源组件。

Commit count: 68

cargo fmt