-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
53 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
local ketama = require 'ketama' | ||
|
||
local ket = ketama.roll('../ketama.servers') | ||
--ket:print_continuum() --don't like! | ||
|
||
local function compare(ket, a, b) | ||
--return the greater, or nil if they are equal | ||
local result = ket:compare(a,b) | ||
if result == 0 then return nil, 'equal' | ||
elseif result == 1 then return a | ||
else return b end | ||
end | ||
|
||
print("server for 'foo':", ket:get_server('foo')) | ||
print("greater of 'foo' and 'bar':", compare(ket, 'foo', 'bar')) | ||
print("hashi of 'foo':", ket:hashi('foo')) | ||
print("md5 of 'foo':", ket:md5digest('foo')) | ||
|
||
ket:smoke() | ||
print("closed") | ||
collectgarbage("collect") | ||
print("kthxbye") |