Browse files

simple echo extension with Lua (nothign is stored in TC)

  • Loading branch information...
1 parent 6085659 commit 0a871fecc53c8d0bd4c71b667dca47fa4697768d @igrigorik committed Jul 7, 2009
Showing with 30 additions and 9 deletions.
  1. +17 −0 echo-command/README.rdoc
  2. +6 −0 echo-command/echo.lua
  3. +7 −0 echo-command/echo.rb
  4. +0 −9 increment-command/incr.rb
View
17 echo-command/README.rdoc
@@ -0,0 +1,17 @@
+= Echo command
+
+Implements a simple echo command (nothign is stored in TC)
+
+== Starting server with incr extension
+ > ttserver -ext echo.lua test.tch
+
+== Executing from command line
+ > tcrmgr ext localhost echo foo bar
+ > foo:bar
+ > tcrmgr ext localhost incr hello world
+ > hello:world
+
+== Executing via Ruby
+
+ > ruby echo.rb
+ > hello:world
View
6 echo-command/echo.lua
@@ -0,0 +1,6 @@
+--
+-- echo.lua
+--
+function echo(key, value)
+ return key .. ":" .. value
+end
View
7 echo-command/echo.rb
@@ -0,0 +1,7 @@
+require 'rubygems'
+require 'rufus/tokyo/tyrant' # sudo gem install rufus-tokyo
+
+t = Rufus::Tokyo::Tyrant.new('127.0.0.1', 1978)
+puts t.ext(:echo, 'hello', 'world')
+
+t.close
View
9 increment-command/incr.rb
@@ -8,12 +8,3 @@
end
t.close
-
-__END__
-
-[ilya@igvita increment-command]# ruby ruby-incr.rb
-2
-4
-6
-8
-10

0 comments on commit 0a871fe

Please sign in to comment.