Key-Value Store
Proc includes flexible key-value store for your documents, collections, and simple values. Use it to create keys, set them to expire, and transform values in place.
You can interact with the key-value store through procs defined in the keyv
package.
Setup
require "proc"
client = Proc.connect("PROCAUTH")
const Proc = require("@proc.dev/client");
const client = Proc.connect("PROCAUTH");
authorization=PROCAUTH
client.keyv.set.call(
bucket: "vad02087", value: "foo"
)
client.keyv.set.call(
undefined, vad02087
);
curl "https://proc.run/keyv/set?bucket=vad02087" --silent \
--header "authorization: bearer $authorization" \
--header "content-type: text/plain" \
--data "foo"
true
Keys are organized into buckets, each key pointing to a simple value like a string, or a complex value like an array or hash. Once created, keys can be retrieved, deleted, or transformed in place.
Setup
require "proc"
client = Proc.connect("PROCAUTH")
const Proc = require("@proc.dev/client");
const client = Proc.connect("PROCAUTH");
authorization=PROCAUTH
client.keyv.set.call(
bucket: "ld0d4623", value: "foo"
)
client.keyv.get.call(
bucket: "ld0d4623"
)
client.keyv.set.call(
undefined, ld0d4623
);
client.keyv.get.call(
undefined, ld0d4623
);
curl "https://proc.run/keyv/set?bucket=ld0d4623" --silent \
--header "authorization: bearer $authorization" \
--header "content-type: text/plain" \
--data "foo"
curl "https://proc.run/keyv/get?bucket=ld0d4623" --silent --request POST \
--header "authorization: bearer $authorization" \
--header "content-type: text/plain"
foo
Setup
require "proc"
client = Proc.connect("PROCAUTH")
const Proc = require("@proc.dev/client");
const client = Proc.connect("PROCAUTH");
authorization=PROCAUTH
client.keyv.set.call(
bucket: "l49ed83b", value: "foo"
)
client.keyv.delete.call(
bucket: "l49ed83b"
)
client.keyv.get.call(
bucket: "l49ed83b"
)
client.keyv.set.call(
undefined, l49ed83b
);
client.keyv.delete.call(
undefined, l49ed83b
);
client.keyv.get.call(
undefined, l49ed83b
);
curl "https://proc.run/keyv/set?bucket=l49ed83b" --silent \
--header "authorization: bearer $authorization" \
--header "content-type: text/plain" \
--data "foo"
curl "https://proc.run/keyv/delete?bucket=l49ed83b" --silent --request POST \
--header "authorization: bearer $authorization" \
--header "content-type: text/plain"
curl "https://proc.run/keyv/get?bucket=l49ed83b" --silent --request POST \
--header "authorization: bearer $authorization" \
--header "content-type: text/plain"
Setup
require "proc"
client = Proc.connect("PROCAUTH")
const Proc = require("@proc.dev/client");
const client = Proc.connect("PROCAUTH");
authorization=PROCAUTH
client.keyv.set.call(
bucket: "z24b88bd", value: "foo"
)
client.keyv.transform.call(bucket: "z24b88bd") {
client.type.string.reverse
}
client.keyv.get.call(
bucket: "z24b88bd"
)
client.keyv.set.call(
undefined, z24b88bd
);
client.keyv.transform.call(undefined, z24b88bd, () => {
return client.type.string.reverse;
});
client.keyv.get.call(
undefined, z24b88bd
);
curl "https://proc.run/keyv/set?bucket=z24b88bd" --silent \
--header "authorization: bearer $authorization" \
--header "content-type: text/plain" \
--data "foo"
curl "https://proc.run/keyv/transform?bucket=z24b88bd" --silent \
--header "authorization: bearer $authorization" \
--header "content-type: application/vnd.proc+json" \
--header "accept: text/plain" \
--data '[["$$", "bucket", ["%%", "z24b88bd", ["()", "type.string.reverse"]]]]'
curl "https://proc.run/keyv/get?bucket=z24b88bd" --silent --request POST \
--header "authorization: bearer $authorization" \
--header "content-type: text/plain"
oof
Value Types
Each key is created with one of the following value types: boolean
, integer
, number
, string
, array
, hash
,
or nil
. If a type is not provided when defining the key, the type will be inferred from the provided value. Set the
value type explicitly by passing the type
argument to keyv.set
or keyv.create
. The given value will be coerced
into the defined type.
Setup
require "proc"
client = Proc.connect("PROCAUTH")
const Proc = require("@proc.dev/client");
const client = Proc.connect("PROCAUTH");
authorization=PROCAUTH
client.keyv.set.call(
bucket: "a25b17a0", value: "42", type: "integer"
)
client.keyv.get.call(
bucket: "a25b17a0"
)
client.keyv.set.call(
undefined, a25b17a0
);
client.keyv.get.call(
undefined, a25b17a0
);
curl "https://proc.run/keyv/set?bucket=a25b17a0&type=integer" --silent \
--header "authorization: bearer $authorization" \
--header "content-type: text/plain" \
--data "1"
curl "https://proc.run/keyv/get?bucket=a25b17a0" --silent --request POST \
--header "authorization: bearer $authorization" \
--header "content-type: text/plain"
42
Expiring Keys
Keys are long-lived and do not expire by default. To define a key with an expiration, pass the ttl
or expiry
argument when calling keyv.set
or keyv.create
. Expiries can be set for or removed from existing keys with
keyv.expire
or keyv.persist
respectively.
Setup
require "proc"
client = Proc.connect("PROCAUTH")
const Proc = require("@proc.dev/client");
const client = Proc.connect("PROCAUTH");
authorization=PROCAUTH
client.keyv.set.call(
bucket: "ldec32ec", value: "foo", ttl: 60
)
client.keyv.set.call(
undefined, ldec32ec
);
curl "https://proc.run/keyv/set?bucket=ldec32ec&ttl=60" --silent \
--header "authorization: bearer $authorization" \
--header "content-type: text/plain" \
--data "foo"
true
Keys are permanently deleted from the key-value store once expired.
Security Model
The keyv
package extends authorization abilities with access control to specific buckets key prefixes. This model
provides a convenient way to control read and write access to specific datasets.
Setup
require "proc"
client = Proc.connect("PROCAUTH")
const Proc = require("@proc.dev/client");
const client = Proc.connect("PROCAUTH");
authorization=PROCAUTH
client.auth.create.call(
abilities: ["keyv.get(bucket: nd992538)"]
)
client.auth.create.call(undefined, {
abilities: ["keyv.get(bucket: nd992538)"]
});
curl https://proc.run/auth/create --silent \
--header "authorization: bearer $authorization" \
--header "content-type: application/vnd.proc+json" \
--header "accept: text/plain" \
--data '[["$$", "abilities", ["keyv.get(bucket: nd992538)"]]]'
Setup
require "proc"
client = Proc.connect("PROCAUTH")
const Proc = require("@proc.dev/client");
const client = Proc.connect("PROCAUTH");
authorization=PROCAUTH
client.auth.create.call(
abilities: ["keyv.set(bucket: v5d7537c)"]
)
client.auth.create.call(undefined, {
abilities: ["keyv.set(bucket: v5d7537c)"]
});
curl https://proc.run/auth/create --silent \
--header "authorization: bearer $authorization" \
--header "content-type: application/vnd.proc+json" \
--header "accept: text/plain" \
--data '[["$$", "abilities", ["keyv.set(bucket: v5d7537c)"]]]'
Setup
require "proc"
client = Proc.connect("PROCAUTH")
const Proc = require("@proc.dev/client");
const client = Proc.connect("PROCAUTH");
authorization=PROCAUTH
client.auth.create.call(
abilities: ["keyv(bucket: y32fe4c0)"]
)
client.auth.create.call(undefined, {
abilities: ["keyv(bucket: y32fe4c0)"]
});
curl https://proc.run/auth/create --silent \
--header "authorization: bearer $authorization" \
--header "content-type: application/vnd.proc+json" \
--header "accept: text/plain" \
--data '[["$$", "abilities", ["keyv(bucket: y32fe4c0)"]]]'
Segmenting data with key prefixes makes it possible to control access to more specific values. For example, you can easily create an authorization that allows a user to access any data but only change their own data.
Setup
require "proc"
client = Proc.connect("PROCAUTH")
const Proc = require("@proc.dev/client");
const client = Proc.connect("PROCAUTH");
authorization=PROCAUTH
client.auth.create.call(
abilities: ["keyv(bucket: fecf89b2, prefix: user:1)"]
)
client.auth.create.call(undefined, {
abilities: ["keyv(bucket: fecf89b2, prefix: user:1)"]
});
curl https://proc.run/auth/create --silent \
--header "authorization: bearer $authorization" \
--header "content-type: application/vnd.proc+json" \
--header "accept: text/plain" \
--data '[["$$", "abilities", ["keyv(bucket: fecf89b2, prefix: user:1)"]]]'
Requirements for Buckets, Keys, & Values
Buckets and keys must be alphanumeric, with exceptions for the following characters: _
, -
, :
. Buckets are limited
to a length of 64 characters. Keys are limited to a length of 128 characters. Values are limited to 512KiB in size.
Bucket names must be unique in context of an account.
Stuck? Want to chat about an idea? Join the community on Discord.