我们的产品均基于Redis开发,但是Redis的基础数据类型并不支持多条件查询,模糊搜索等,因此我们修改了Redis源码,通过辅助索引的方式,将Redis改造成可以像SQL数据那样使用的数据库。
OnceDB并不改变Redis的数据存储结构,Redis数据库文件可以直接在OnceDB中操作,然后再返回Redis中使用。
全文搜索
OnceDB提供直接搜索指令,支持 String 和 Hash 等对象,
搜索String: search pattern operator value
搜索 String 类型的键,可使用 search
# 创建数据
set test1 'this is testing'
> OK
set test2 'this is article'
> OK
# 搜索数据
search test* ~ article
1) test1
2) this is testing
3) test2
4) this is article
operator操作符支持: = 完全匹配 ~ 部分匹配 > >= < <= 比较匹配
搜索Hash: hsearch pattern field operator value ...
hsearch 可以实现对 Hash 对象的搜索。
在redis中没有表的概念,一般使用 schema:id 的键名包含表名和主键。比如 user:001 为 user 表,主键值为001的 Hash 对象。
# 创建 Hash 数据<