Commit Graph

161 Commits

Author SHA1 Message Date
Anton
7b25c85f8f refactor: sqlx - add vkey view v0.4.0 2024-05-05 15:55:32 +05:00
Anton
31c07ca9a4 refactor: sqlx - simpler view queries 2024-05-05 15:55:24 +05:00
Anton
5b59de3888 refactor: docker - use valkey-cli for smaller image 2024-05-05 15:30:27 +05:00
Anton
4aff4a9033 fix: command - distinguish between key not found and zero value 2024-05-04 23:33:37 +05:00
Anton
91ba6db411 impr: command - dbsize, ttl, type 2024-05-04 20:54:30 +05:00
Anton
1a54e3205b impr: rkey - len 2024-05-04 20:53:15 +05:00
Anton
043f1c123b impr: docker - healthcheck using ping (fix #17) 2024-05-04 20:17:47 +05:00
Anton
05aeb4be39 refactor: rstring - single-query set 2024-05-04 10:13:25 +05:00
Anton
5acaeaa21e refactor: sqlx - rename key_id to kid 2024-05-04 01:24:50 +05:00
Anton
4f3ce933b4 refactor: sqlx - strict tables 2024-05-04 01:06:46 +05:00
Anton
d692027cfc refactor: disallow the same key for different data types
Duplicate key names, introduced in 1b55ad8, do not play
well with rkey methods like Get, so I decided to undo
the change and settle for unique key names and
"key type mismatch" checking.

Unlike the v0.3 implementation, Redka now checks for
"key type mismatch" situations using the NOT NULL constraint
on rkey update instead of a separate ON UPDATE trigger, so
there is (almost) no performance penalty.

The general advice still applies:

Please don't use the same key for different data types.
It's a VERY bad idea.
2024-05-03 17:08:16 +05:00
Anton
24af28e0f0 refactor: rkey - incr version on expire/persist 2024-05-03 09:32:21 +05:00
Anton
4e76dda6e2 test: rstring - check key version 2024-05-03 09:23:42 +05:00
Anton
2901796811 refactor: rzset - store zset length 2024-05-03 09:13:19 +05:00
Anton
d8be92e8f5 refactor: rhash - store hash length 2024-05-03 08:05:07 +05:00
Anton
da2359ac13 refactor: rlist - store list length 2024-05-02 23:28:03 +05:00
Anton
dcd246d115 refactor: rkey - hardcode initial key version 2024-05-01 23:49:55 +05:00
Anton
b3e7a47be5 refactor: core - rename TypeSortedSet to TypeZSet 2024-05-01 23:44:33 +05:00
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
Anton
21951bc7e2 doc: readme - remove hard wrap in tables 2024-04-30 14:56:03 +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
fa44b345fa doc: readme - v0.3.0 2024-04-26 12:25:25 +05:00
Anton
dc1d2b353c doc: readme - set command mapping 2024-04-26 11:53:59 +05:00
Anton
1757da1a6d doc: redka - examples v0.3.0 2024-04-26 11:29:07 +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