java - How to cache data in server using files -


i writing application in need store huge amount of data in db , cache same. when ever client requests comes, server needs fetch data cache , return same.

here how doing it: (offline process) 1. have spring batch application gets json file (around 6mb in size). 2. reads each object , store in db. 3. approximately 17k records being stored in db.

(online process) 4. when ever request comes server (web app - spring web mvc), app gets data db , returns response.

i planing avoid db storage here. instead of using db, can add file in file server , cache data present in file whenever server started?

let me know if there existing methodology.

caching won't replacement persistence. can store data in file system instead of db whole point of having db in first place data storage , retrieval faster in db in normal file system because of better structuring of data , indexing (along huge advantage of ease of querying data). can dump data in db in huge file formats (not recommended)

for caching, can use memcached or redis. note caching not 100% reliable. can configure cache specify time after cache should cleared. need keep updating cache data whenever create/update data in db. if cache gets full, least-used resources cleared cache first accommodate new data.

the ideal solution use scalable (read non-relational) db caching layer memcache. on side note, extremely easy use memcache spring (i haven't used redis in application yet). since mention json data formats, take @ mongodb persistence.


Comments

Popular posts from this blog

html5 - What is breaking my page when printing? -

c# - must be a non-abstract type with a public parameterless constructor in redis -

ajax - PHP/JSON Login script (Twitter style) not setting sessions -