<s> import logging <EOL> import redis <EOL> from rackclient . lib import RACK_CTX <EOL> LOG = logging . getLogger ( __name__ ) <EOL> FIFO = <NUM_LIT:3> <EOL> PORT = <NUM_LIT> <EOL> def get_host ( ) : <EOL> return RACK_CTX . proxy_ip <EOL> class Shm ( object ) : <EOL> def __init__ ( self ) : <EOL> self . host = get_host ( ) <EOL> self . port = PORT <EOL> self . r = redis . StrictRedis ( host = self . host , port = self . port , db = FIFO ) <EOL> def read ( self , key ) : <EOL> data = self . r . get ( key ) <EOL> return data <EOL> def write ( self , key , value ) : <EOL> return self . r . set ( key , value ) <EOL> def list_read ( self , key ) : <EOL> count = self . r . llen ( key ) <EOL> return self . r . lrange ( key , <NUM_LIT:0> , count ) <EOL> def list_write ( self , key , value ) : <EOL> return self . r . rpush ( key , value ) <EOL> def list_delete_value ( self , key , value ) : <EOL> return self . r . lrem ( key , <NUM_LIT:1> , value ) <EOL> def delete ( self , key ) : <EOL> return self . r . delete ( key ) </s>
