Commit Graph

21 Commits

Author SHA1 Message Date
Anton
818954d339 refactor: use vfs=memdb instead of mode=memory&cache=shared
Shared cache is discouraged. The supported alternative
(and increasingly recommended by SQLite developers),
is the memdb VFS (which I believe is supported by all drivers).
I'm sure modernc has it, and mattn also does if compiled with
SQLITE_ENABLE_DESERIALIZE, which became the default in 2021.

https://github.com/ncruces/go-sqlite3/issues/94#issuecomment-2157679766
2024-06-10 21:55:49 +05:00
Anton
4aff4a9033 fix: command - distinguish between key not found and zero value 2024-05-04 23:33:37 +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
4e76dda6e2 test: rstring - check key version 2024-05-03 09:23:42 +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
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