• Post Reply Bookmark Topic Watch Topic
  • New Topic

Caching flights in business tier - a question

Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,

It is very possible that searches by 2 different users can have common results. I want introduce a caching service in business tier and cache flight search results. When 1st user performs a flight search, I would save the results of 1st search in cache. When 2nd user performs a similar search, I want to reuse the results(only if they are not invalidated) from the cache for this user.

Many issues came to my mind if I decide to have caching service in my design. for e.g.

* process for invalidating the cached results
* incompleteness of these results, if 2nd search is a bit different
and might yield in some additional flights which are not available in cache.

Can somebody please answer these questions for me related to the above description ?

1) Will this design work?
2) Has anyone passed with this kind of caching service(sharing search results of 2 different users) in their design?

Required Field
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Caching does not work that way.

Typically, you would store things in the cache indexed with a cache-key, which you can use later to look up the cache. So if the first user searches for a particular set of flights, you will need to construct a unique cache-key for that set of results and put them in the cache (this is the first time).

Whenever someone else comes along and performs a search, you construct a unique cache-key out of the search parameter values. Then you use that cache-key to try and hit the cache. If you hit in the cache, you retrieve results from the cache itself. If you miss in the cache, you retrieve results and put them in the cache, using the new cache-key.

Whenever someone adds a new flight thru the admin interface, you invalidate all cache-keys that have the specific city or the date-range, so that a cache miss happens the next time it is looked up.

This is a very generic description. This process has been extensively researched and optimized by caching product vendors. Like load-balancing, replication, distributed caching etc.

If you use a boxed product, you are good to go... if you are designing it in your architecture from scratch, you better be vary of all the pitfalls... read as much as you can abt the theoretical concepts behind it.

All the best.
Gravity is a harsh mistress. But this tiny ad is pretty easy to deal with:
the new thread boost feature: great for the advertiser and smooth for the coderanch user
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!