惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

Google DeepMind News
Google DeepMind News
Application and Cybersecurity Blog
Application and Cybersecurity Blog
P
Privacy International News Feed
T
Tor Project blog
Spread Privacy
Spread Privacy
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
L
Lohrmann on Cybersecurity
博客园_首页
T
Tailwind CSS Blog
A
Arctic Wolf
P
Proofpoint News Feed
H
Help Net Security
V
Vulnerabilities – Threatpost
云风的 BLOG
云风的 BLOG
Microsoft Azure Blog
Microsoft Azure Blog
月光博客
月光博客
大猫的无限游戏
大猫的无限游戏
F
Fortinet All Blogs
罗磊的独立博客
阮一峰的网络日志
阮一峰的网络日志
酷 壳 – CoolShell
酷 壳 – CoolShell
aimingoo的专栏
aimingoo的专栏
D
DataBreaches.Net
博客园 - 聂微东
Security Latest
Security Latest
V
Visual Studio Blog
腾讯CDC
D
Darknet – Hacking Tools, Hacker News & Cyber Security
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
Microsoft Security Blog
Microsoft Security Blog
I
InfoQ
S
Schneier on Security
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
Cyberwarzone
Cyberwarzone
T
Tenable Blog
B
Blog RSS Feed
博客园 - 三生石上(FineUI控件)
N
Netflix TechBlog - Medium
The Cloudflare Blog
U
Unit 42
Latest news
Latest news
AWS News Blog
AWS News Blog
J
Java Code Geeks
N
News and Events Feed by Topic
Blog — PlanetScale
Blog — PlanetScale
G
Google Developers Blog
S
SegmentFault 最新的问题
M
MIT News - Artificial intelligence
Help Net Security
Help Net Security

Deno

Deno 2.8 | Deno Claw Patrol: an open-source security firewall for agents | Deno Fresh 2.3: Zero JS by default, View Transitions, and Temporal support | Deno Deno 2.7: Temporal API, Windows ARM, and npm overrides | Deno Build a dinosaur runner game with Deno, pt. 6 | Deno Build a dinosaur runner game with Deno, pt. 5 | Deno Deno Deploy is Generally Available | Deno Introducing Deno Sandbox | Deno Build a dinosaur runner game with Deno, pt. 4 | Deno Build a dinosaur runner game with Deno, pt. 3 | Deno Build a dinosaur runner game with Deno, pt. 2 | Deno React / Next.js Denial-of-Service Vulnerability: Deno Deploy users protected | Deno Deno 2.6: dx is the new npx | Deno Build a dinosaur runner game with Deno, pt. 1 | Deno React Server Functions / Next.js Vulnerability: Deno Deploy users protected | Deno My highlights from the new Deno Deploy | Deno Deno's Other Open Source Projects | Deno How Deno protects against npm exploits | Deno Help Us Raise $200k to Free JavaScript from Oracle | Deno Deno 2.5: Permissions in the config file | Deno Fresh 2.0 Graduates to Beta, Adds Vite Support | Deno Deno 2.4: deno bundle is back | Deno JavaScript™ Trademark Update | Deno What's coming to JavaScript | Deno A brief history of JavaScript | Deno Reports of Deno's Demise Have Been Greatly Exaggerated | Deno An Update on Fresh | Deno How Plaid migrated 100 services to a new database platform 5x faster with Deno | Deno Deno 2.3: Improved deno compile, local npm packages, and more | Deno Add JSR packages with pnpm and Yarn | Deno Zero-config Debugging with Deno and OpenTelemetry | Deno Exploring Art with TypeScript, Jupyter, Polars, and Observable Plot | Deno Deno v Oracle Update 3: Fighting the JavaScript Trademark | Deno Build a custom RAG AI agent in TypeScript and Jupyter | Deno How to get deep traces in your Node.js backend with OTel and Deno | Deno toranoana.deno #20 登録受付中(2025年3月14日) | Deno Node just added TypeScript support. What does that mean for Deno? | Deno The Dino 🦕, the Llama 🦙, and the Whale 🐋 | Deno Publish a lint rule, get a prize | Deno Deno 2.2: OpenTelemetry, Lint Plugins, node:sqlite | Deno If you're not using npm specifiers, you're doing it wrong | Deno How Deno's documentation is evolving | Deno Oracle justified its JavaScript trademark with Node.js—now it wants that ignored | Deno Introducing the JSR open governance board | Deno Intro to Wasm in Deno | Deno Announcing OpenAI on JSR | Deno Deno in 2024 | Deno Goodbye WinterCG, welcome WinterTC | Deno Build a SolidJS app with Deno | Deno Run your Next.js SSR app on Deno Deploy | Deno Solve Advent of Code 2024 with Deno and Win Prizes! | Deno Deno v. Oracle: Canceling the JavaScript Trademark | Deno Deno 2.1: Wasm Imports and other enhancements | Deno Build a Typesafe API with tRPC and Deno | Deno Self-contained Executable Programs with Deno Compile | Deno Build a Database App with Drizzle ORM and Deno | Deno Introducing your new JavaScript package manager: Deno | Deno Announcing Growthbook on JSR | Deno Build an Astro site with Deno | Deno How to convert CommonJS to ESM | Deno Announcing Deno 2 | Deno The Final Touches: What’s New In v2.0.0-rc.10 | Deno Announcing Stable V8 Bindings for Rust | Deno Deno 2.0 Release Candidate | Deno Secure, efficient private npm registries with Cloudsmith and Deno | Deno Painting the Plane as We Fly It: Designing JSR | Deno Introducing Web Cache API support on Deno Deploy | Deno Deno 1.46: The Last 1.x Release | Deno Protect your cloud spend with new Deno Deploy spend limits | Deno What we got wrong about HTTP imports | Deno Benchmarking AWS Lambda Cold Starts Across JavaScript Runtimes | Deno Announcing Supabase on JSR | Deno Deno 1.45: Workspace and Monorepo Support | Deno Introducing KV Backup for Deno Subhosting | Deno A Gentle Intro to TypeScript | Deno Announcing Hono on JSR | Deno How We Made the Deno Language Server Ten Times Faster | Deno How the Guardian uses Deno to audit accessibility and performance across their 2.7 million articles | Deno Introducing More Flexible Domain Association for Deno Subhosting | Deno The stabilization process of the Standard Library has begun | Deno Deno 1.44: Private npm registries, improved Node.js compat, and performance boosts | Deno How we built a secure, performant, multi-tenant cloud platform to run untrusted code | Deno The Deno Standard Library is now available on JSR | Deno How to document your JavaScript package | Deno Your Low Code Solution Needs an Escape Hatch | Deno Deno 1.43: Improved Language Server performance | Deno How Slack used Deno to save months of engineering effort in launching their new platform | Deno JSR Is Not Another Package Manager | Deno Announcing the Hookdeck SDK on JSR | Deno Announcing the Neon Serverless Driver on JSR | Deno An intro to TSConfig for JavaScript Developers | Deno How we built JSR | Deno How Netlify used Deno Subhosting to build a successful edge functions product | Deno Introducing Simpler Project Creation in Deno Deploy | Deno Deno 1.42: Better dependency management with JSR | Deno Introducing deployctl, the command line interface for Deno Deploy | Deno Introducing JSR - the JavaScript Registry | Deno How to add Monaco to a Next.js app and securely run untrusted user code | Deno Survey Results and Roadmap | Deno Deno 1.41: smaller deno compile binaries | Deno
Build Real-time Applications with the new "watch" API in Deno KV | Deno
2023-12-11 · via Deno

Deno KV, our ACID-compliant key-value database built right into the runtime, was a big step towards our vision of radically simplifying cloud development by removing boilerplate and configuration. Instead of juggling API keys and provisioning a database, you can connect to a database in a single line of code:

const kv = await Deno.openKv();
And, if you use it with Deno Deploy, your data can be replicated globally and scales without any further setup.

We’ve continued to ship a ton of features for Deno KV, such as an open source self-hostable server, the ability to remotely connect to a managed Deno KV instance, and continuous backup to object storage. But today, we’re introducing a new feature that will simplify building an entire class of real time applications - kv.watch:

let seen = "";
for await (const [messageId] of kv.watch([["last_message_id", roomId]])) {
  const newMessages = await Array.fromAsync(kv.list({
    start: ["messages", roomId, seen, ""],
    end: ["messages", roomId, messageId, ""],
  });
  
  await websocket.write(JSON.stringify(newMessages));
  seen = messageId;
}
A real-time chat application using `kv.watch`.

Supported as of Deno 1.38.5 and on Deno Deploy, kv.watch allows you to listen to changes to your Deno KV keys, which simplifies building:

  • real-time UI updates, such as social media newsfeeds or notifications
  • chat applications or chat rooms like Slack and Discord
  • collaborative editors like Google Docs

In this blog post, we’ll go over:

  • The new .watch() function
  • Building real-time updates
  • Watching for updates on Deno Deploy
  • More use cases and examples
  • What’s next
Learn about the new watch feature in the above YouTube video.

The new .watch() 👀 function

The new .watch() function accepts an array of keys, and returns a ReadableStream that emits a new value anytime the watched keys change their versionstamp.

In the below example, we watch for updates on keys ["foo"] and ["bar"]:

const db = await Deno.openKv();

const stream = db.watch([["foo"], ["bar"]]);
for await (const entries of stream) {
  entries[0].key; 
  entries[0].value; 
  entries[0].versionstamp; 
  entries[1].key; 
  entries[1].value; 
  entries[1].versionstamp; 
}

Note that the most keys you can pass in a single kv.watch call is 10.

In order to add kv.watch into a site or app, you would need to use it with server-side events or websockets.

Building real-time updates

For a more practical example, the code below uses kv.watch to listen to changes to the post’s comments and like counts, then dispatches them to the client with server-sent events:

import { Application, Router } from "https://deno.land/x/oak/mod.ts";

const app = new Application();
const router = new Router();


router.get("/api/blog_post_updates", async (ctx) => {
  const target = ctx.sendEvents();
  const postId = ctx.url.searchParams.get("post_id");
  for await (
    const [{ value: lastCommentId }, { value: likeCount }] of kv.watch([
      ["lastCommentId", postId],
      ["likeCount", postId],
    ])
  ) {
    target.dispatchMessage({ lastCommentId, likeCount });
  }
});

app.use(router.routes());
await app.listen({ port: 80 });

The client needs to create a connection at the endpoint /api/blog_post_updates. Then, the client will receive server-side events with new comments and like count, which it can render in HTML. The UI will then render updates without requiring a page reload.

Watching for updates on Deno Deploy

Deno KV on Deno Deploy is an all-in-one solution for scalable, reliable and ACID-compliant storage, with all the necessary primitives for building modern applications:

No matter which region an isolate is running in, kv.watch change notifications are delivered to the isolate with minimal latency. With our high-performance transaction processing architecture built on top of FoundationDB, kv.watch scales to hundreds of thousands of concurrent clients.

Pricing

There’s no change to the pricing for Deno KV on Deno Deploy. However, every time an entry is returned in the ReadableStream response from kv.watch, it is considered a “read”.

More use cases and examples

To provide more examples on using kv.watch, we have updated our Deno KV showcase apps to include KV watch:

These examples give you an idea of the real-time or multi-user collaboration applications that you can build with Deno KV watch.

For more resources:

What’s next

Deno KV, alongside other cloud primitives such as Deno Queues and Deno Cron, are built right into the runtime, which allows you to build faster without worrying about configuration, provisioning, or scaling infrastructure. Deno KV’s new kv.watch further simplifies building real-time applications by letting you detect changes to Deno KV.

We’re always open to feedback and feature requests! Feel free to join our growing Discord or create an issue here.

We just launched Deno Cron! 🦕🕒

Create scheduled jobs on Deno Deploy in minutes.