Popularity
2.8
Growing
Activity
0.0
Stable
3
4
0
Programming language: Crystal
License: GNU General Public License v3.0 or later
Tags:
Low Level Bindings
Latest version: v0.1.1
kt alternatives and similar shards
Based on the "Low level bindings" category.
Alternatively, view kt alternatives based on common mentions on social networks and blogs.
-
termbox-crystal
Bindings, wrapper, and utilities for termbox (terminal interface library) in Crystal -
wkhtmltopdf-crystal
Crystal C bindings and wrapper for libwkhtmltox library -
serialport.cr
Crystal bindings for libserialport: cross-platform library for accessing serial ports.
Clean code begins in your IDE with SonarLint
Up your coding game and discover issues early. SonarLint is a free plugin that helps you find & fix bugs and security issues from the moment you start writing code. Install from your favorite IDE marketplace today.
Promo
www.sonarlint.org
Do you think we are missing an alternative of kt or a related project?
README
KT
Crystal bindings for Kyoto Tycoon. It uses a connection pool to maintain multiple connections.
Installation
Add this to your application's shard.yml
:
dependencies:
kt:
github: kuende/kt
Usage
require "kt"
kt = KT.new(host: "127.0.0.1", port: 1978, poolsize: 5, timeout: 5.0)
# Setting
kt.set("japan", "tokyo") # set a key
kt.set_bulk({"china" => "beijing", "france" => "paris", "uk" => "london"})
kt.get("japan") # => "tokyo"
kt.get_bulk(["japan", "france"]) # => {"japan" => "tokyo", "france" => "paris"}
kt.get("foo") # => nil
kt.get!("foo") # => raises KT::RecordNotFound
kt.remove("japan") # => true
kt.remove("japan") # => false, key japan is not found anymore
kt.remove!("japan") # => raises KT::RecordNotFound becouse key japan is not found
kt.remove_bulk(["japan", "china"]) # => 1 (number keys deleted)
kt.clear # deletes all records in the database
kt.set_bulk({"user:1" => "1", "user:2" => "2", "user:4" => "4"})
kt.match_prefix("user:") # => ["user:1", "user:2", "user:3", "user:4", "user:5"]
# Compare and swap
kt.set("user:1", "1")
kt.cas("user:1", "1", "2") # => true
kt.cas("user:1", "1", "3") # => false, previous value is "2"
kt.cas("user:1", nil, "3") # => false, record already exists with value "2"
kt.cas("user:2", nil, "1") # => true, no record exists so it was set
kt.cas("user:1", "2", nil) # => true, record is removed becouse it was present
kt.cas("user:1", "2", nil) # => false, it fails becouse no record with this key exists
# cas! raises where cas returns false
kt.cas!("user:1", "1", "2") # => KT::CASFailed, no record exists with this value
kt.count # => 2 keys in database
TODO
- [ ] implement expiration for most commands
- [ ] work with multiple servers
Contributing
- Fork it ( https://github.com/kuende/kt/fork )
- Create your feature branch (git checkout -b my-new-feature)
- Commit your changes (git commit -am 'Add some feature')
- Push to the branch (git push origin my-new-feature)
- Create a new Pull Request