• 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:
  • Campbell Ritchie
  • Ron McLeod
  • Rob Spoor
  • Tim Cooke
  • Junilu Lacar
Sheriffs:
  • Henry Wong
  • Liutauras Vilda
  • Jeanne Boyarsky
Saloon Keepers:
  • Jesse Silverman
  • Tim Holloway
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Mikalai Zaikin
  • Piet Souris

best strategy to cache static data

 
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi all
I am learning about caching and wanted guidance on what is the best strategy for caching static data.  
I have some metadata that I will need to load from a file .  The file describes the fields I need to map from the payload to another external api field.  These fields do change often. What type of caching should I use
The caveat is there will be more fields that will be coming in future release until its production ready.

There will be API calls that invoke methods that will invoke these definitions from the cache

Should I
1) read file and store in memory [app server]
2) create static variables
2) should I use redis
3) should I use mongodb

if I do use a cache and this is static data . Do I need to use TTL ? or an eviction policy . I do not think so . But wanted to confirm if there was a use case

Thanks for any help or suggestion

-Ryder
 
Saloon Keeper
Posts: 7094
165
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
2 is not really a different option, is it? There isn't a big different between option 1 with an instance field of a class that is probably a singleton, and option 2.

I wouldn't recommend introducing Redis just for this, unless other considerations make that a useful option.

For evicting and re-reading you could either build in an option to trigger that manually, or via an MBean that could be triggered externally (or even automatically, if so desired).
 
Saloon Keeper
Posts: 13248
291
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Maybe first tell us what you mean by "static data". I can't reconcile my definition with your explanation that the fields change often.
 
Saloon Keeper
Posts: 24287
167
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Even more important, what sort of system is this? A web application? A desktop app? A document manger? Source code repository? ???

Systems may have multiple caches and multiple levels of cache. Until we have some idea of the purpose of the system and its expected data flows, it's hard to say.

Also, MongoDB is a full-fledged NoSQL database and while you can cache using it - or IBM's SB/2 for that matter, it's note generally responsive enough to be in the same league as redis.

It is a good idea for have a cache with a purge policy unless your cache is at least as large as the set of items to be cached. I once discovered - the hard way - meaning days of tests - that the Oracle JDBC driver I was using had a bottomless cache. Well, the cache might have been bottomless, but the webapp/server threw OutOfMemory after about 2 and a half days of processing.

In fairness, this was officially documented behavior. I found the webpage that mentioned it in a locked washroom down in the basement with a filing cabinet in front of it and a sign on the door saying "Beware of the Leopard".
 
You showed up just in time for the waffles! And this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic