Skip to content

Add configurable cache deltas#642

Open
eskerda wants to merge 4 commits intomasterfrom
cache-deltas
Open

Add configurable cache deltas#642
eskerda wants to merge 4 commits intomasterfrom
cache-deltas

Conversation

@eskerda
Copy link
Copy Markdown
Owner

@eskerda eskerda commented Nov 21, 2023

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

@eskerda eskerda force-pushed the cache-deltas branch 3 times, most recently from ce48643 to 4f87f82 Compare November 22, 2023 14:52
@eskerda eskerda mentioned this pull request Dec 28, 2023
@eskerda eskerda force-pushed the master branch 2 times, most recently from 58d91af to f01e89e Compare September 13, 2025 02:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant