Add Support for Hash Field Expiration Commands (HEXPIRE, HEXPIREAT, HGETEX, HPERSIST)
English / 中文
Add Support for Hash Field Expiration Commands (HEXPIRE, HEXPIREAT, HGETEX, HPERSIST)
Introduction
Valkey 9.0 has introduced new commands for setting expiration times on individual hash fields: HEXPIRE, HEXPIREAT, HGETEX, and HPERSIST. These commands allow developers to set expiration times for individual fields independently, enabling finer-grained and more flexible cache control. This enhancement is particularly beneficial for user sessions, temporary data, or cache segmentation scenarios.
According to the Valkey 9.0 release announcement (https://www.linuxmi.com/valkey-9-0.html), these new commands break previous limitations and provide more granular control over hash field expiration.
Proposal
I propose that Kvrocks should also implement these new commands to enhance its compatibility with Redis/Valkey and provide users with more advanced caching capabilities:
-
HEXPIRE- Set expiration time for a hash field with a TTL in seconds https://redis.io/docs/latest/commands/hexpire/ -
HEXPIREAT- Set expiration time for a hash field with an absolute Unix timestamp https://redis.io/docs/latest/commands/hexpireat/ -
HGETEX- Get the value of a hash field and set its expiration time https://redis.io/docs/latest/commands/hexpireat/ -
HPERSIST- Remove expiration time from a hash field## About Valkey https://redis.io/docs/latest/commands/hpersist/
Valkey is a drop-in replacement for Redis that maintains full compatibility while being developed under a truly open-source license (BSD). Major cloud providers including Alibaba, Huawei, Tencent, Amazon, Google, and Ericsson have joined the Valkey initiative.
As noted in industry reports (https://mp.weixin.qq.com/s/6JY3Sl2pLBCLT6Ry1lPdHA), Valkey currently has 6 core maintainers from leading technology companies, ensuring robust community support and ongoing development.
Furthermore, Arch Linux has officially deprecated Redis in favor of Valkey (https://mp.weixin.qq.com/s/yOBjPk1Gqsp2ljQB-3T0nA), highlighting the growing adoption of Valkey as the preferred Redis alternative.
The primary reason for this shift is that Redis changed its license from BSD-3-Clause to RSALv2 and SSPLv1 on March 20, 2024, which many consider to no longer qualify as open-source software. Valkey, as a fork of Redis under the BSD license, represents a community-driven alternative promoted by major companies including Amazon, Google, and Oracle.
Implementing these new hash expiration commands would position Kvrocks as a more complete Redis/Valkey-compatible solution, aligning with the direction of the broader open-source community.
添加对哈希字段过期命令的支持 (HEXPIRE、HEXPIREAT、HGETEX、HPERSIST)
简介
Valkey 9.0 引入了新的命令来为单个哈希字段设置过期时间:HEXPIRE、HEXPIREAT、HGETEX 和 HPERSIST。这些命令允许开发人员独立地为各个字段设置过期时间,从而实现更精细和灵活的缓存控制。对于用户会话、临时数据或缓存细分等场景来说,这一增强功能尤其有益。
根据 Valkey 9.0 发布公告 (https://www.linuxmi.com/valkey-9-0.html),这些新命令打破了之前的限制,提供了对哈希字段过期更精细的控制。
建议
建议 Kvrocks 也实现这些新命令,以增强其与 Redis/Valkey 的兼容性,并为用户提供更高级的缓存功能:
HEXPIRE- 使用以秒为单位的 TTL 为哈希字段设置过期时间HEXPIREAT- 使用绝对 Unix 时间戳为哈希字段设置过期时间HGETEX- 获取哈希字段的值并设置其过期时间HPERSIST- 移除哈希字段的过期时间
关于 Valkey
Valkey 是 Redis 的直接替代品,在保持完全兼容的同时采用真正的开源许可(BSD)进行开发。包括阿里、华为、腾讯、亚马逊、谷歌和爱立信在内的主要云提供商已加入 Valkey 倡议。
正如行业报告中所述 (https://mp.weixin.qq.com/s/6JY3Sl2pLBCLT6Ry1lPdHA),Valkey 目前有 6 位来自领先技术公司的核心维护者,确保了强大的社区支持和持续的开发。
此外,Arch Linux 已正式弃用 Redis 转而支持 Valkey (https://mp.weixin.qq.com/s/yOBjPk1Gqsp2ljQB-3T0nA),这突显了 Valkey 作为首选 Redis 替代品日益增长的采用率。
这种转变的主要原因是 Redis 在 2024 年 3 月 20 日将其许可证从 BSD-3-Clause 更改为 RSALv2 和 SSPLv1,许多人认为这不再符合开源软件的资格。Valkey 作为 BSD 许可证下的 Redis 分支,代表了由亚马逊、谷歌和甲骨文等大公司推动的社区驱动替代方案。
实现这些新的哈希过期命令将使 Kvrocks 成为更完整的 Redis/Valkey 兼容解决方案,与更广泛的开源社区发展方向保持一致。