• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

How to add the possibility to refresh cache if object has changed

 
Ranch Hand
Posts: 620
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello all
i made simple caching mechanism ( service locator pattern )
that holds objects from different types , now i have problem on implement the
possibility of refreshing the cache if some object has bean changed , how can i keep
track so my cache will hold the up to date objects ?
thanks
 
Ranch Hand
Posts: 1296
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I suppose you could use a form of the Observer/Observable pattern. In its simplest form your object would be the Observable and the cache object would register with it as an Observer. Each time your Object was mutated in some form it would fire an event to all Observers registered to it to let them know that something happened. Google for - Observer pattern java - and you'll get a number of useful links. Does that sound like it might help solve your problem?
 
reply
    Bookmark Topic Watch Topic
  • New Topic