• Post Reply Bookmark Topic Watch Topic
  • New Topic

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

 
Meir Yan
Ranch Hand
Posts: 599
  • Mark post as helpful
  • send pies
  • 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
 
Garrett Rowe
Ranch Hand
Posts: 1296
  • Mark post as helpful
  • send pies
  • 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?
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!