def main(verbose=False): """ Main program code. Assume running on a single server with cache stored in memory """ # Initialize a new LRU cache with size of max_size address_cache = LRUCache.SimpleCache(max_size=50000) # Accept first simple user input input_address_str_1 = input("1. First address to look up? ") # Check the cache sales_tax_1 = address_cache.fast_rate_lookup(input_address_str_1) if sales_tax_1 == -1: # Call the PSL function if verbose: print("Missing from cache -- calling PSL function") sales_tax_1 = sales_tax_lookup(input_address_str_1) # Add new sales_tax value to the cache address_cache.set(input_address_str_1, sales_tax_1) if verbose: print("Sales tax rate for address (%s): %0.2f" % (input_address_str_1, sales_tax_1)) print("Current cache size: %d" % address_cache.size()) # Accept second simple user input input_address_str_2 = input("2. Second address to look up? ") # Check the cache sales_tax_2 = address_cache.fast_rate_lookup(input_address_str_2) if sales_tax_2 == -1: # Call the PSL function if verbose: print("Missing from cache -- calling PSL function") sales_tax_2 = sales_tax_lookup(input_address_str_2) # Add new sales_tax value to the cache address_cache.set(input_address_str_2, sales_tax_2) if verbose: print("Sales tax rate for address (%s): %0.2f" % (input_address_str_2, sales_tax_2)) print("Current cache size: %d" % address_cache.size())