2 Replies Latest reply on Feb 6, 2008 10:59 AM by brian.stansberry

    How to update cache when new rows has been added into table?

    narendrakg

      Hi,

      I am using query cache in Spring+Hibernate+JBoss+Weblogic.

      Now the table I am caching is updated by other vendor (using insert query directly into table and without using application that is caching the table).

      Once the insert of new rows is done , my query (executed from application through hibernate) return the same rows that has been cached.

      Is it possible to reflect the new rows into cache? If yes, How?

      Thanks & Regards,
      Narendra Gupta

        • 1. Re: How to update cache when new rows has been added into ta
          mircea.markus

          basically your cache needs to be notified by the data store whenever a certain table data is modified, and at that point it should cleanup the cache(the DBMS might help you on this, e.g. JServer).
          If you can stale data for short periods of time is acceptable, you can write an eviction policy that will call periodically the database for external updates and cleanup the cache accordingly.

          • 2. Re: How to update cache when new rows has been added into ta
            brian.stansberry

            Once you've solved the problem of figuring out how to be made aware that the external app has changed the db, suggest you ask on the Hibernate forums for the best approach on how to remove data from the cache. Hibernate has some APIs for flushing stuff from the cache; using those APIs is a better approach than trying to directly manipulate the cache yourself.