<s> import urlparse <EOL> from couchbase import Couchbase , exceptions as cb_exc <EOL> class CouchbaseStorage ( object ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , settings ) : <EOL> url = urlparse . urlparse ( settings . COUCHBASE_URL ) <EOL> params = dict ( [ <EOL> param . split ( '<STR_LIT:=>' ) <EOL> for param in url . query . split ( '<STR_LIT:&>' ) <EOL> ] ) <EOL> self . couchbase = Couchbase ( host = url . hostname . split ( '<STR_LIT:U+002C>' ) , <EOL> bucket = url . path . strip ( '<STR_LIT:/>' ) , <EOL> port = url . port or <NUM_LIT> , <EOL> ** params ) <EOL> def save ( self , key , value , expire = None ) : <EOL> res = self . couchbase . set ( key , value , ttl = expire ) <EOL> return res . success <EOL> def clear ( self , key ) : <EOL> res = self . couchbase . delete ( key ) <EOL> return res . success <EOL> def clear_all_keys ( self ) : <EOL> """<STR_LIT>""" <EOL> return "<STR_LIT>" <EOL> def load ( self , key ) : <EOL> try : <EOL> res = self . couchbase . get ( key ) <EOL> return res . value <EOL> except cb_exc . NotFoundError : <EOL> pass <EOL> def size ( self ) : <EOL> """<STR_LIT>""" <EOL> return "<STR_LIT>" <EOL> def bootstrap ( settings ) : <EOL> return CouchbaseStorage ( settings ) </s>
