#NEWLINE# def test_cache_decorator_include_self( redis_unix_socket_path ) : #NEWLINE# #INDENT# cache = Cache ( redis_options = { #NEWLINE# #INDENT# 'unix_socket_path' : cache , #NEWLINE# #UNINDENT# } ) #NEWLINE# class User ( object ) : #NEWLINE# #INDENT# def __init__( self , user_id ) : #NEWLINE# #INDENT# self . user_id = user_id #NEWLINE# #UNINDENT# def __str__( self ) : #NEWLINE# #INDENT# return ( '<User %s>' % self . user_id ) #NEWLINE# #UNINDENT# @ cache . cache ( include_self = True ) #NEWLINE# def load( self , name , offset ) : #NEWLINE# #INDENT# return ' ' . join ( ( 'load' , name , str ( offset ) ) ) #NEWLINE# #UNINDENT# #UNINDENT# user01 = User ( 1 ) #NEWLINE# user02 = User ( 2 ) #NEWLINE# assert ( user01 . load ( 'name' , 'offset' ) == 'load name offset' ) #NEWLINE# assert ( user02 . load ( 'name' , 'offset' ) == 'load name offset' ) #NEWLINE# class User ( object ) : #NEWLINE# #INDENT# def __init__( self , user_id ) : #NEWLINE# #INDENT# self . user_id = user_id #NEWLINE# #UNINDENT# def __str__( self ) : #NEWLINE# #INDENT# return ( '<User %s>' % self . user_id ) #NEWLINE# #UNINDENT# @ cache . cache ( include_self = True ) #NEWLINE# def load( self , name , offset ) : #NEWLINE# #INDENT# return ' ' . join ( ( 'load02' , name , str ( offset ) ) ) #NEWLINE# #UNINDENT# #UNINDENT# user01 = User ( 1 ) #NEWLINE# user02 = User ( 2 ) #NEWLINE# assert ( user01 . load ( 'name' , 'offset' ) == 'load name offset' ) #NEWLINE# assert ( user02 . load ( 'name' , 'offset' ) == 'load name offset' ) #NEWLINE# assert cache . invalidate ( user01 . load , 'name' , 'offset' ) #NEWLINE# assert ( user01 . load ( 'name' , 'offset' ) == 'load02 name offset' ) #NEWLINE# assert ( user02 . load ( 'name' , 'offset' ) == 'load name offset' )