keyv.count
0.000005

Counts keys.

Arguments
bucketrequired
The bucket the keys are stored under.
prefix
Restricts the count to keys that match the given prefix.
Return Value
The number of keys in the bucket.
something went wrong :(
Counting keys in a bucket
Setup
authorization=PROCAUTH
require "proc"

client = Proc.connect("PROCAUTH")
const Proc = require("@proc.dev/client");
const client = Proc.connect("PROCAUTH");
client.keyv.set.call(
  bucket: "hf78aa39", value: "foo"
)

client.keyv.count.call(
  bucket: "hf78aa39"
)
client.keyv.set.call(
  undefined, hf78aa39
);

client.keyv.count.call(
  undefined, hf78aa39
);
curl "https://proc.run/keyv/set?bucket=hf78aa39" --silent \
--header "authorization: bearer $authorization" \
--header "content-type: text/plain" \
--data "foo"

curl "https://proc.run/keyv/count?bucket=hf78aa39" --silent --request POST \
--header "authorization: bearer $authorization" \
--header "content-type: text/plain"
 

1

If prefix is passed, the count is constrained to keys that match the given prefix.

something went wrong :(
Counting keys that match a prefix
Setup
authorization=PROCAUTH
require "proc"

client = Proc.connect("PROCAUTH")
const Proc = require("@proc.dev/client");
const client = Proc.connect("PROCAUTH");
client.keyv.set.call(
  bucket: "h6d90778", value: "foo"
)

client.keyv.set.call(
  bucket: "h6d90778", value: "bar"
)

client.keyv.count.call(
  bucket: "h6d90778", prefix: "a"
)
client.keyv.set.call(
  undefined, h6d90778
);

client.keyv.set.call(
  undefined, h6d90778
);

client.keyv.count.call(
  undefined, h6d90778
);
curl "https://proc.run/keyv/set?bucket=h6d90778" --silent \
--header "authorization: bearer $authorization" \
--header "content-type: text/plain" \
--data "foo"

curl "https://proc.run/keyv/set?bucket=h6d90778" --silent \
--header "authorization: bearer $authorization" \
--header "content-type: text/plain" \
--data "bar"

curl "https://proc.run/keyv/count?bucket=h6d90778&prefix=a" --silent --request POST \
--header "authorization: bearer $authorization" \
--header "content-type: text/plain"
 

1


Stuck? Want to chat about an idea? Join the community on Discord.