This topic created in 1511 days ago, the information mentioned may be changed or developed.
如 mysql 的结构类似:
id name
-- --
1 apple
2 banana
程序直接使用 insert values ('apple') 来获得一个新的 id = 3 的对应数据条目
类似这种,不一定使用 sql 语句,比如 add('apple') 这种语句之类的, 有什么 nosql 的数据库,可以显示吗?
6 replies 2022-03-25 21:35:13 +08:00  | | 1 Mithril Mar 24, 2022 你用 UUID 都是递增的。 主要是很多 NoSQL 的使用场景都是多节点集群,你要这种严格递增很难在多机情况下保证的。 |
 | | 2 timethinker Mar 24, 2022 nosql 大多都是分布式数据库,如果引入自增的这种特性,意味着每一次插入都需要协调维护一个计数器,这会引入额外的同步开销,因此最好是自己在应用层去维护这个计数器,而不是依靠数据库本身提供类似的功能。 |
 | | 3 GuangXiN Mar 24, 2022 via Android redis 分两步做喽
$id = hincrby "xxx_id" 1 hset "xxx" $id "apple" |
 | | 6 GuangXiN Mar 25, 2022 const id = await redis.command('hincrby', 'xxx_id', 1); await redis.command('hset', 'xxx', id, JSON.stringify(someValueToStore)); |