#NEWLINE# def set( self , key , path = '/' , limit = 100 , time = HOUR ) : #NEWLINE# #INDENT# ' Sets the rate for the given key and path,\n            where limit is the maximum number of requests in the given time (e.g., 100/hour).\n        ' #NEWLINE# p = ( '/' + path . strip ( '/' ) ) #NEWLINE# q1 = 'delete from `rate` where key=? and path=?;' #NEWLINE# q2 = 'insert into `rate` values (?, ?, ?, ?);' #NEWLINE# self . execute ( q1 , ( key , p ) , commit = False ) #NEWLINE# self . execute ( q2 , ( key , p , limit , time ) ) #NEWLINE# with self . lock : #NEWLINE# #INDENT# self . cache [ ( key , p ) ] = ( 0 , limit , time , _time . time ( ) ) #NEWLINE# self . _rowcount += 1 #NEWLINE# #UNINDENT# return ( key , path , limit , time )