Add configurable cache deltas
Current caching strategies are undefined. We use caching for both storing authentication nonces and for systems that use a single feed for more than one network within the system.
This PR tries to add a configurable layer for caching that is completely user defined. Any configuration that we would explicitly provide and hardcode would not be suitable for all uses of this library. In the cases where it makes sense to hardcode it (auth), it is providen by a new cache_for argument to scraper.request.
The configuration layer is provided as a list of hashes that are defined using regex syntax. Rules follow this pattern: module::tag::method::url. This is a sample configuration
[
# hourly for list of stations
{'db::.*::get_station_information': 60 * 60},
# daily for types of vehicles
{'db::.*::get_vehicle_types': 60 * 60 * 24},
# daily for gbfs root url
{'db::.*::get_feeds': 60 * 60 * 24},
# anything else does not get cached
{'db::.*': 0},
# hourly for list of stations
{'callabike::.*::get_station_information': 60 * 60},
# daily for types of vehicles
{'callabike::.*::get_vehicle_types': 60 * 60 * 24},
# daily for gbfs root url
{'callabike::.*::get_feeds': 60 * 60 * 24},
# cache anything else, since all instances use a single feed
{'callabike::.*': 60},
# Cache all nextbike calls, since system uses single feeds
{'.*nextbike-live.xml': 60},
# Cache all publibike calls, since system uses single feeds
{'publibike::.*': 60},
]
I have yet not decided if I want to include a set of defaults or not. Probably yes