Sha256: 1e63c2db9eac846dc992b541474839c1afa3f0610ee28d68e76259e38dec3a4f

Contents?: true

Size: 1.02 KB

Versions: 19

Compression:

Stored size: 1.02 KB

Contents

require File.expand_path("../example_setup", __FILE__)
require "github/kv"

# Create new instance using ActiveRecord's default connection.
kv = GitHub::KV.new { ActiveRecord::Base.connection }

# Get a key.
pp kv.get("foo")
#<GitHub::Result:0x3fd88cd3ea9c value: nil>

# Set a key.
kv.set("foo", "bar")
# nil

# Get the key again.
pp kv.get("foo")
#<GitHub::Result:0x3fe810d06e4c value: "bar">

# Get multiple keys at once.
pp kv.mget(["foo", "bar"])
#<GitHub::Result:0x3fccccd1b57c value: ["bar", nil]>

# Check for existence of a key.
pp kv.exists("foo")
#<GitHub::Result:0x3fd4ae55ce8c value: true>

# Check for existence of key that does not exist.
pp kv.exists("bar")
#<GitHub::Result:0x3fd4ae55c554 value: false>

# Check for existence of multiple keys at once.
pp kv.mexists(["foo", "bar"])
#<GitHub::Result:0x3ff1e98e18e8 value: [true, false]>

# Set a key's value if the key does not already exist.
pp kv.setnx("foo", "bar")
# false

# Delete a key.
pp kv.del("bar")
# nil

# Delete multiple keys at once.
pp kv.mdel(["foo", "bar"])
# nil

Version data entries

19 entries across 19 versions & 1 rubygems

Version Path
github-ds-0.5.4 examples/kv.rb
github-ds-0.5.3 examples/kv.rb
github-ds-0.5.2 examples/kv.rb
github-ds-0.5.0 examples/kv.rb
github-ds-0.4.0 examples/kv.rb
github-ds-0.3.0 examples/kv.rb
github-ds-0.2.11 examples/kv.rb
github-ds-0.2.10 examples/kv.rb
github-ds-0.2.9 examples/kv.rb
github-ds-0.2.8 examples/kv.rb
github-ds-0.2.7 examples/kv.rb
github-ds-0.2.6 examples/kv.rb
github-ds-0.2.5 examples/kv.rb
github-ds-0.2.4 examples/kv.rb
github-ds-0.2.3 examples/kv.rb
github-ds-0.2.2 examples/kv.rb
github-ds-0.2.1 examples/kv.rb
github-ds-0.2.0 examples/kv.rb
github-ds-0.1.0 examples/kv.rb