Created
August 15, 2009 14:04
-
-
Save clofresh/168357 to your computer and use it in GitHub Desktop.
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
#!/bin/bash | |
HOST=127.0.0.1 | |
PORT=1978 | |
SID=1 | |
UPDATE_LOG_DIR=ulog/$SID | |
MASTER_HOST=127.0.0.1 | |
MASTER_PORT=1979 | |
mkdir -p $UPDATE_LOG_DIR | |
ttserver -host $HOST \ | |
-port $PORT \ | |
-ulog $UPDATE_LOG_DIR \ | |
-sid $SID \ | |
-mhost $MASTER_HOST \ | |
-mport $MASTER_PORT | |
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
#!/bin/bash | |
HOST=127.0.0.1 | |
PORT=1979 | |
SID=2 | |
UPDATE_LOG_DIR=ulog/$SID | |
MASTER_HOST=127.0.0.1 | |
MASTER_PORT=1978 | |
mkdir -p $UPDATE_LOG_DIR | |
ttserver -host $HOST \ | |
-port $PORT \ | |
-ulog $UPDATE_LOG_DIR \ | |
-sid $SID \ | |
-mhost $MASTER_HOST \ | |
-mport $MASTER_PORT | |
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
import pytyrant | |
import time | |
t1 = pytyrant.PyTyrant.open('127.0.0.1', 1978) | |
t2 = pytyrant.PyTyrant.open('127.0.0.1', 1979) | |
print t2.get('foo', 'nothing here') # 'nothing here' | |
# Writing to t1 replicates to t2 | |
t1['foo'] = 'bar' | |
print t2.get('foo', 'nothing here') # 'foo' | |
# Tokyo Tyrant also speaks the memcached protocol | |
import memcache | |
mc = memcache.Client(['127.0.0.1:1978', '127.0.0.1:1979']) | |
print mc.get('foo') # 'bar' | |
mc.set('yo', 'sup') # Assigns ('yo', 'sup') pair to one of the servers in the pool | |
# Both Tyrant servers should have ('yo', 'sup') because of master-master replication | |
print t1.get('yo', 'nothing in t1') # 'sup' | |
print t2.get('yo', 'nothing in t2') # 'sup' | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment