0
votes

In trying to be a pragmatic programmer, I'm trying to work out a caching strategy for services and rates returned from the UPS and USPS apis.

My first thought would be to store following:

  • postal code (normalized, no spaces, simply as a key)
  • carrier
  • weight
  • service
  • cost
  • transit time
  • country code (ISO 3166-1 alpha-2)

My primary goal is to set a short timeout for the API call, and fail over to cached data. For situations where "estimated" rates are acceptable (ex: shipping calculator on a shopping cart), I plain to use the cached data first.

EDIT I fully intend to prime this cache on a regular basis from existing user data.

1
Hi Eric, I'm sure I could help you with this, but I'm not quite sure what you're asking for. Are you asking how to use a cache to store this data?Travis Reeder
I was wondering if anybody had any suggestions on what to store. More of a question about design-pattern rather than actual code.Eric C

1 Answers

0
votes

Seems like you answered your own question. When looking at weight I'd cache the billable weight based on DIM size if you have it as that's the largest variance.