您现在的位置是:首页 > 文章详情

Bun v1.2.9 发布:内置 Redis 客户端 Bun.redis

日期:2025-04-09点击:105

Bun v1.2.9 已发布,此版本修复了 48 个 bug,其他变化包括:

  • Bun 现在内置了 Redis 客户端Bun.redis
  • Bun.S3Client中的ListObjectsV2支持
  • 更多的libuv符号
  • require.extensions兼容性

公告写道,Bun 现在内置了一个速度非常快的 Redis/Valkey 客户端——采用 Zig 从头开始编写。

import { redis, RedisClient } from "bun";

// Reads $REDIS_URL from environment
await redis.set("foo", "bar");
const value = await redis.get("foo");
console.log(value); // "bar"

await redis.ttl("foo"); // 10 seconds
// or use redis.set("foo", "bar", "EX", 10)

const custom = new RedisClient("redis://localhost:6379", {
  // options
});

await custom.set("foo", "bar");

性能表现:

❯ bun-latest redis.mjs
[146.08ms] Bun.redis GET 'greeting' 10000 batches of 10
[211.52ms]   ioredis GET 'greeting' 10000 batches of 10
→ Bun.redis is 44.82% faster

[527.04ms] Bun.redis GET 'greeting' 10000 batches of 100
[834.25ms]   ioredis GET 'greeting' 10000 batches of 100
→ Bun.redis is 58.29% faster

[4.22s] Bun.redis GET 'greeting' 10000 batches of 1000
[7.83s]   ioredis GET 'greeting' 10000 batches of 1000
→ Bun.redis is 85.39% faster


❯ node redis.mjs
  ioredis GET 'greeting' 10000 batches of 10: 270.837ms
  ioredis GET 'greeting' 10000 batches of 100: 1.181s
  ioredis GET 'greeting' 10000 batches of 1000: 10.095s

详情查看:https://bun.sh/blog/bun-v1.2.9

原文链接:https://www.oschina.net/news/343617/bun-v1-2-9
关注公众号

低调大师中文资讯倾力打造互联网数据资讯、行业资源、电子商务、移动互联网、网络营销平台。

持续更新报道IT业界、互联网、市场资讯、驱动更新,是最及时权威的产业资讯及硬件资讯报道平台。

转载内容版权归作者及来源网站所有,本站原创内容转载请注明来源。

文章评论

共有0条评论来说两句吧...

文章二维码

扫描即可查看该文章

点击排行

推荐阅读

最新文章