• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • paul wheaton
  • Ron McLeod
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Piet Souris
Bartenders:

Caching flights in business tier - a question

 
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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?

Thanks,
Satheesh
 
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic