RethinkDB 2.2: atomic changefeeds

2022-04-08 00:00:00 专区 订阅 代码 付费 复制


原文链接: rethinkdb.com

Today, we’re pleased to announce RethinkDB 2.2 (Modern Times). Download it now!

RethinkDB 2.2 includes over 120 enhancements, significantly improves performance, memory usage and scalability, adds new ReQL commands, and ships with atomic changefeed support. Some of the major improvements in the 2.2 release include:

  • Atomic changefeeds: the changes command now accepts an optional argument called includeInitial, which allows atomically reading existing data and processing new results with a single query.
  • Optimized fetches: the getAll code path has been optimized to perform a single network round trip, which results in an 8x performance improvement.
  • Parallel scans: fetching large amounts of sequential data from RethinkDB now scales linearly with the size of the cluster.
  • Improved memory usage: memory usage on large datasets has been reduced by over 50%.
  • New ReQL commands: We added a new values command, and Peter Hollows expanded r.uuid to support user defined hashes.

Atomic changefeeds

One of the most common patterns when building realtime web or mobile applications is to render the page and then update it any time there is new information. For example, if you’re presenting your users with a leaderboard, you’d typically want to render the leaderboard right away, and then update it when it changes.

Prior to RethinkDB 2.2 you could accomplish it by running two separate queries: one to fetch initial data, and another to listen to changes.

// Get the initial data for top ten players
var leaderboard = r.table('gameplays')
                   .filter(r.row.gt(1000))
                   .run(conn);
// Open a changefeeed to receive updates
var changes = r.table('gameplays')
               .filter(r.row.gt(1000))
               .changes()
               .run(conn);
复制代码

相关文章