I'm creating a layered web application. Briefly it's:
Domain logic: Java and servlets
Business logic: MySQL
I've considerable amounts of records within the database that contains information on books. Additionally the applying will be utilised by lots of customers simultaneously. I wish to enable customers to input a book's "title" inside a search text area , say "book1" and display a drop lower list using jquery autocomplete.
The records in database aren't updatable given that they won't ever change.
Thinking about solid design designs,what's best (performance and speed smart) :
Preloading these database records right into a cache object in the domain logic and allow the customers search (query) them out of this object? Or querying from the database using something similar to MySQL full-text search?
If using MySQL full-text search, I'm worried about getting plenty of calls towards the database by many people customers simultaneously. For preloading right into a cache object, i don't know if this sounds like generally a great software practice, does anybody recommend it? Should i put a timer for records to stay cached in memory?
Which of those 2 techniques is more suitable? exist other better techniques for such situations?
I discovered an answer and hope this answer can help those who coping an identical situation:
I'll be utilizing a software engineering design pattern, that we used frequently previously, known as Identity Map.
Only this time around, since records aren't updatable (i.e. not changeable), I'll be only using the caching functionality from the identity map. And So I will is going to be loading the records in the database into this identity map object when the server begins. By doing this a person will query them from the domain layer, thus faster and fewer calls towards the database.
One problem to think about, which is when adding new records through the administration, with this situation I'll be using another design pattern known as "observer pattern" (you can study about this in this book).
Just in case you coping an identical situation, advisable is by using MySQL indexing. I made use of it around the column from the "book's title" make it possible for faster loading within the cache object, because during my situation the cache object will contain only book(s) title(s) since while using search area within the UI, the consumer is just worried about a book's title. PS: other book particulars is going to be loaded only if user clicks a book's title within the drop lower list, and at this time u might opt for another Identity map holding the particulars . The explanation for this architecture is the fact that, realistically speaking won't u have the books (using their particulars) out of your database looked (loaded) by all of the customers of the application simultaneously... thus to reduce server memory and bandwidth usage you initially compromise loading the entire column of book names in memory for faster searching of available book names BUT their particulars (ie more room in memory) is going to be loaded only if required by a person and will also be stored in another identity map for use by another user searching for the similar book with same particulars. For me this minimizes memory usage around the server and fewer calls towards the database to obtain particulars that happen to be fetched by other customers before.