0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

Deno: Redis のデータを読む (Read)

Last updated at Posted at 2020-05-18

次のプログラムで作成したデータを読みます。
Deno: Redis のデータを作成 (Create)

プログラム

redis_read.ts
// ---------------------------------------------------------------
//	redis_read.ts
//
//					Feb/27/2023
//
// ---------------------------------------------------------------
import { connect } from "https://deno.land/x/redis/mod.ts"
// ---------------------------------------------------------------
function display_line_proc (key:string,json_str:string)
{
	const data = JSON.parse (json_str)

	var out_str: string = key + "\t"
	out_str  += data.name + "\t"
	out_str += data.population + "\t"
	out_str += data.date_mod
	console.log (out_str)
}

// ---------------------------------------------------------------
console.error ("*** 開始 ***")

const client = await connect({ hostname: "127.0.0.1", port: 6379 })

const reply = await client.sendCommand("keys", "*")

const keys:string[] = reply.value()

for (var it in keys)
	{
	const key:string = keys[it].toString()
	const reply = await client.get(key)
	if (reply != null)
		{
		display_line_proc (key,reply)
		}
	}

console.error ("*** 終了 ***")

// ---------------------------------------------------------------

実行コマンド

deno run --allow-net redis_read.ts

確認したバージョン

$ deno --version
deno 1.40.5 (release, x86_64-unknown-linux-gnu)
v8 12.1.285.27
typescript 5.3.3
0
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?