Commit Graph

102 Commits

Author SHA1 Message Date
Anton
4459afa8cf refactor: allow keys with same name and different types 2024-05-01 23:38:18 +05:00
Anton
fc9070d238 refactor: change ErrNotFound value 2024-05-01 17:58:27 +05:00
Anton
c7eb7e7931 feat: command - list 2024-05-01 17:06:36 +05:00
Anton
cfb9cc3a22 refactor: convert value to bytes before saving to db 2024-05-01 03:11:30 +05:00
Anton
4f7ebf2b30 refactor: reformat sql 2024-05-01 00:34:35 +05:00
Anton
f9f11bdcaf refactor: single-statement execs
Redka aims to support both mattn and modernc SQLite drivers,
but they are incompatible in how they handle parameters in
multi-statement Exec calls.

Creating two separate Exec strategies seems premature at this
point, so I refactored all Exec queries back to single statements
and changed all params to positional. This way, both mattn and
modernc drivers work fine.
2024-04-30 20:36:09 +05:00
Anton
bd8208bae4 refactor: command - better encapsulation and simpler tests 2024-04-30 15:54:27 +05:00
yinzhidong
e01aa11486 feat: command - ping (#19) 2024-04-30 14:54:36 +05:00
Anton
5e789cf1bd refactor: command - subpackages 2024-04-30 02:01:19 +05:00
Anton
e37e3774aa feat: lists 2024-04-29 20:36:31 +05:00
Anton
a1941e3e12 refactor: separate read-write and read-only db handles 2024-04-28 17:49:11 +05:00
Anton
ce5edee195 refactor: remove db transactions for single-query operations 2024-04-28 09:26:54 +05:00
Anton
1b55ad8652 refactor: sqlx - delete TypedError 2024-04-28 08:49:25 +05:00
Anton
c6bdaf08a2 refactor: allow the same key for different data types
Because Redis uses a global key namespace, it's possible to
create a key of one type (e.g., a string) and then try to
work with is as if it were of another type (e.g., a hash).
I call this a "key type mismatch" situation.

Redis' handling of key type mismatches is a mess. Sometimes
it allows them (SET), sometimes it ignores them (MGET),
sometimes it forbids them (HSET).

Starting with this commit, Redka takes a more consistent
approach. Now you can use the same key for different data
types, and everything will work fine. With a small caveat:
the `type` column in the `rkey` table will store the last
modified type (it doesn't affect any operations though).

Having said that. Please don't use the same key for
different data types. It's a VERY bad idea.
2024-04-28 08:47:19 +05:00
Anton
2a0dfa94c4 refactor: rkey - move Get function to methods 2024-04-28 07:52:17 +05:00
Anton
caccf401e2 refactor: rkey - delete unused CountType 2024-04-28 07:21:51 +05:00
Anton
c99c7e048d refactor: rzset - do not use rkey.DeleteType 2024-04-28 07:21:01 +05:00
Anton
4e8c59f5cf refactor: rhash - sql query readability 2024-04-28 01:34:57 +05:00
Anton
63ee7ea27c refactor: rstring - sql query readability 2024-04-28 01:32:40 +05:00
Anton
b668258493 refactor: rkey - sql query readability 2024-04-28 01:28:23 +05:00
Anton
0c320a363e rzset - single-query add/inter/union, positional sql params 2024-04-28 01:23:49 +05:00
Anton
a00b5525d1 refactor: rhash - single-query set, positional sql params 2024-04-28 00:40:29 +05:00
Anton
320e5c76d5 refactor: rkey - positional sql params 2024-04-28 00:40:22 +05:00
Anton
9104eb0915 impr: rstring - single-query set, positional sql params
- Perform set and update in a single database roundtrip
  (exec can run multiple queries)
- Change named SQL parameters to positional (faster)
2024-04-28 00:39:47 +05:00
Anton
c58976ae50 refactor: sqlx - schema formatting 2024-04-26 10:47:09 +05:00
Anton
d7e0e9a777 refactor: command - always return nil on error 2024-04-26 10:35:38 +05:00
Anton
8435f8d81d refactor: command - remove msetnx
I never quite understood the use case for MSETNX, so I searched
the Redis repo issues and StackOverflow. I didn't find a single
real-world scenario for using this command, so I decided to remove it.
2024-04-26 10:25:09 +05:00
Anton
4eb6ded8b9 impr: command - set shortcut for simple cases 2024-04-26 10:14:22 +05:00
Anton
65d8134596 feat: command - zinter, zunion, zrange and friends 2024-04-26 09:28:51 +05:00
Anton
2bebd328f4 refactor: rzset - range doc and tests 2024-04-24 11:07:29 +05:00
Anton
4340c9f0f2 feat: command - zinter 2024-04-23 00:44:06 +05:00
Anton
396e7fdeae feat: command - zadd, zcard, zcount 2024-04-22 23:14:03 +05:00
Anton
ebe56e7ae3 impr: command - set keepttl 2024-04-22 13:05:25 +05:00
Anton
f4bef7d2a2 impr: command - set get 2024-04-22 12:46:58 +05:00
Anton
82d2d91430 impr: command - set exat/pxat 2024-04-22 12:38:58 +05:00
Anton
39cc66be61 impr: parser - named parser 2024-04-22 12:08:24 +05:00
Anton
922356d851 impr: parser - command arguments parser 2024-04-22 08:42:52 +05:00
Anton
00487b197a refactor: command - better scan parsing 2024-04-22 00:31:14 +05:00
Anton
05564efb2e refactor: command - better hscan parsing 2024-04-22 00:28:48 +05:00
Anton
4a5e705ec3 refactor: command - better set parsing 2024-04-22 00:20:28 +05:00
Anton
746a90baab refactor: rstring - GetSet/SetExists/SetNotExists -> SetWith 2024-04-21 23:52:13 +05:00
Anton
2319c3c83f refactor: redka - SortedSet -> ZSet 2024-04-21 20:58:06 +05:00
Anton
cdfdf9779c fix: rhash - Scan typo 2024-04-21 20:46:43 +05:00
Anton
0c2083f925 refactor: rkey - ErrNotFound if key does not exist 2024-04-21 20:44:23 +05:00
Anton
7472da955b refactor: rkey - sql constant group 2024-04-21 19:36:01 +05:00
Anton
3675955af1 refactor: rkey - alphabetical method order 2024-04-21 19:30:50 +05:00
Anton
94117d01a9 refactor rkey - extract scanner 2024-04-21 19:15:31 +05:00
Anton
dd9641ee40 refactor: rstring - query args order 2024-04-21 18:01:49 +05:00
Anton
992dd8cc2c refactor: rstring - ErrNotFound if key does not exist 2024-04-21 17:53:43 +05:00
Anton
b028ccd043 refactor: rstring - sql constant group 2024-04-21 16:45:45 +05:00