本文整理汇总了Python中kyotocabinet.DB.get方法的典型用法代码示例。如果您正苦于以下问题:Python DB.get方法的具体用法?Python DB.get怎么用?Python DB.get使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类kyotocabinet.DB
的用法示例。
在下文中一共展示了DB.get方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: get_post_by_date
# 需要导入模块: from kyotocabinet import DB [as 别名]
# 或者: from kyotocabinet.DB import get [as 别名]
def get_post_by_date(key, db_file):
item = None
db = DB()
if not db.open("{0}".format(db_file), DB.OREADER | DB.OCREATE):
print "Could not open database."
item = db.get(key)
db.close()
if item is not None:
return loads(item)
return dict()
示例2: decorated_function
# 需要导入模块: from kyotocabinet import DB [as 别名]
# 或者: from kyotocabinet.DB import get [as 别名]
def decorated_function(*args, **kwargs):
# Debug
if not current_app.config['CACHE']:
return f(*args, **kwargs)
db = DB()
db.open("/tmp/page_cache.kch")
res = None
fancy = hash("{}{}{}".format(db_meta_info()['count'], request.url, f.func_name))
res = db.get(fancy)
if not res:
res = f(*args, **kwargs)
db.set(fancy, res)
db.close()
return res
示例3: BKNNModel
# 需要导入模块: from kyotocabinet import DB [as 别名]
# 或者: from kyotocabinet.DB import get [as 别名]
#.........这里部分代码省略.........
ckeyfmt = '>' + ( 'I' * len(x) );
cvalfmt = '>I' + ( 'f' * len(x) );
self._cdata.append( pack( ckeyfmt, *x_ ), pack( cvalfmt, y, *x ) );
if len( self._sample_x ) < 50000:
assert len( self._sample_x ) == len( self._sample_y );
assert len( self._sample_x ) == len( self._sample_c );
assert len( self._sample_x ) == len( self._sample_b );
assert len( self._sample_x ) == len( self._sample_x_ );
self._sample_y.append( y );
self._sample_c.append( c );
self._sample_b.append( b );
self._sample_x.append( x );
self._sample_x_.append( x_ );
return False;
def _init( self ):
self._needs_initialization = False;
c = self._ddata.cursor();
c.jump();
keyfmt = '>' + ( 'I' * ( 1 + self._len_c + self._len_b ) );
valfmt = '>Q';
while True:
r = c.get( True );
if not r:
break;
dbkey = unpack( keyfmt, r[0] );
dbval = unpack( valfmt, r[1] )[ 0 ];
additional_count = dbval;
y = dbkey[ 0 ];
for ( i, value_of_variable_i ) in enumerate( dbkey[ 1: ] ):
if not i in self._dmarginals:
self._dmarginals[ i ] = {};
self._dmarginals[ i ][ (y,value_of_variable_i) ] \
= self._dmarginals[ i ].get( (y,value_of_variable_i), 0 ) \
+ additional_count;
for ( i, count_by_val ) in self._dmarginals.items():
total = 0;
total_neg = 0;
total_pos = 0;
for ( ( y, val ), cnt ) in count_by_val.items():
total += cnt;
if y == 0:
total_neg += cnt;
elif y == 1:
total_pos += cnt;
示例4: str
# 需要导入模块: from kyotocabinet import DB [as 别名]
# 或者: from kyotocabinet.DB import get [as 别名]
not db.set("user:"+email+":avatarid", "1722559") or\
not db.set("user:"+email+":login_count", "179") or\
not db.set("user:"+email+":login_date", "2012.06.02") or\
not db.set("user:"+email+":sex", "male") or\
not db.set("user:"+email+":id", "10") or\
not db.set("user:"+email+":ups", "100") or\
not db.set("user:"+email+":downs", "10") or\
not db.set("user:"+email+":hits", "110") or\
not db.set("user:count", "100") or\
not db.set("user:id:1", "[email protected]") or\
not db.set("user:id:2", "[email protected]") or\
not db.set("user:id:3", "[email protected]"):
print >>sys.stderr, "set error: " + str(db.error())
# retrieve records
o= format_datetime(float(db.get("file:"+key+":createdata")))
v=db.get("file:"+key+":key")
va=db.get("mark:"+cid+":description")
val = db.get("category:"+cid+":name")
valu = db.get("category:1:id")
value = db.get("user:id:1")
if value:
print o
print v
print va
print val
print valu
print value
else:
print >>sys.stderr, "get error: " + str(db.error())