Commit Graph

17 Commits

Author SHA1 Message Date
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
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
ebe56e7ae3 impr: command - set keepttl 2024-04-22 13:05:25 +05:00
Anton
82d2d91430 impr: command - set exat/pxat 2024-04-22 12:38:58 +05:00
Anton
746a90baab refactor: rstring - GetSet/SetExists/SetNotExists -> SetWith 2024-04-21 23:52:13 +05:00
Anton
992dd8cc2c refactor: rstring - ErrNotFound if key does not exist 2024-04-21 17:53:43 +05:00
Anton
8b9f99f072 refactor: rstring - alphabetical method order 2024-04-21 16:37:55 +05:00
Anton
eda58d11e3 refactor: redka - database options 2024-04-14 01:29:19 +05:00
Anton
4acc6ed711 refactor: use specific repo types instead of interfaces 2024-04-13 23:03:47 +05:00
Anton
7cabece4be refactor: redka - shorter error names 2024-04-11 21:18:03 +05:00
Anton
601626b729 refactor: redka - do not use aliased types 2024-04-11 20:50:52 +05:00
Anton
a7f4d2d497 refactor: core - ErrInvalidType -> ErrInvalidValueType 2024-04-11 20:39:55 +05:00
Anton
db1b3eaa6a impr: rstring, rhash - check key type 2024-04-11 20:39:43 +05:00
Anton
12b2cf4a46 refactor: rstring - remove name redundancy 2024-04-11 16:15:34 +05:00
Anton
2c8eba045b refactor: rstring - return a map from GetMany 2024-04-11 16:15:34 +05:00
Anton
4f7de216e5 refactor: rstring - []KVPair -> map[string]any 2024-04-11 16:15:34 +05:00
Anton
4bdc0f365a test: move rkey and rstring tests into subpackages 2024-04-10 09:21:06 +05:00