4 Replies Latest reply: Jul 12, 2012 6:48 AM by 948372 RSS

    Time-based aging, how to refresh this kind of cache group automatically?

      Hi gurus,

      I have made an AWT cache group, and I want to use Time-based Aging on it.

      This is the statements that I create the cache group:

      create dynamic asynchronous writethrough global cache group awt_timewindow from
      hr.job_history (employee_id number(6) not null,
      start_date date not null,
      end_date date not null,
      job_id varchar2(10) not null,
      department_id number(4),
      primary key (employee_id,start_date))

      Then I load data to cache by this command:
      load cache group awt_timewindow commit every 0 rows;

      My data looks like (the 3rd column is end_date):
      < 101, 1997-09-21 00:00:00, 2001-10-27 00:00:00, AC_ACCOUNT, 110 >
      < 101, 2001-10-28 00:00:00, 2005-03-15 00:00:00, AC_MGR, 110 >
      < 101, 2011-01-03 00:00:00, 2012-11-11 00:00:00, MK_REP, 220 >
      < 200, 2010-08-01 00:00:00, 2012-07-10 00:00:00, MK_REP, 90 >
      < 201, 2004-02-17 00:00:00, 2007-12-19 00:00:00, MK_REP, 20 >
      < 202, 2010-01-01 00:00:00, 2012-02-02 00:00:00, MK_REP, 250 >

      As the statement says, I want to keep the records that end_date meets (system_time - end_date) <= 180 days.
      And I want the cache group can be refreshed ASAP, in my example, I want to get the latest results in 3 seconds.

      However, when I changed the system date to a long time ago, e.g.: January 1st, 2000, then I tried to select from this table after 5 seconds, I still got the original results, the cache group is not refreshed automatically instantly.
      If I try it once and once again, about several minutes later, I could get the updated cache sometimes, but more times still without lucky.

      If I manually refresh the table by calling: call ttAgingScheduleNow('hr.job_history');
      Then try again, I got the updated cache immediately (obviously this is what I want to see).

      So, my problem is how to configure the Time-based Aging (or something else) to refresh the cache group quickly. I believe there should be something I missed.

      Thanks a lot!


      Edited by: 945369 on 2012-7-12 上午2:59
        • 1. Re: Time-based aging, how to refresh this kind of cache group automatically?
          A few things to note...

          1. Never change the system time by a large amount while TimesTen is running, especially backwards. The results are 'undefined' but in general many different problems will arise. Yoiu need to stop TimesTen (including the main daemon) if yiou want to set the date back in time. This issue apoplies to lots of softyware not just TimesTen.

          2. Changing the time to a point in the past will not trigger aging. You need to set the time to a point > 180 days in the future... Rows that are candidates to be aged are those where (system_date - end_date) > 180 days. If system_date < end_date then this condition cannot be true...

          3. The aging comparison is based on the defined units (days in this case). The result of (system_date - end_date) is truncated to days before comparison with the lifetime so rows will only become candidates for aging when the day in system_date rolls over. Checking for aging eveyr 3 secodns is pointless in thsi case. If you want an aging granularity of secodns but a lifetime of 180 days then you should specify the lifetime as 15552000 seconds (180 * 24 * 60 * 60).

          • 2. Re: Time-based aging, how to refresh this kind of cache group automatically?
            Hello Chris,

            Thanks a lot for your great advice!

            The Time-based Aging function of TT performs very well if I set the system date (to 01/01/2000) before starting ttdaemonadmin.
            And then, if I change system time to any time later than the original one I set, the cache group updated immediately! Wow! It's cool!

            BTW, I noticed that when I connected to my DSN, I always get this message when I try to "select * from hr.job_history".

            Command> select * from hr.job_history;
            3374: Member may contain stale global cache group table data. Please attach to the grid to clean up the data
            The command failed.

            I called ttrepstop before exit the last connection.

            Is there a way for how to avoid this warning? Thanks again!

            Best Regards,
            • 3. Re: Time-based aging, how to refresh this kind of cache group automatically?
              It sounds like, at some point, you attached your TT database to a grid and created a global cache group but that now the database is not attached to the grid and so grid functionality is not available and hence the global CG tables may have stale data.

              If you want to use cache grid, as opposed to non-grid cache, then you should start the cache agent and reattach to the grid. If you don't need cache grid functionality it's best to create a non-global cache group. For more information, study the section on cache grid in the TT Cache User's Guide.

              • 4. Re: Time-based aging, how to refresh this kind of cache group automatically?
                I am just reading the User's Guide.

                Thank you, Chris! Have a nice day!

                Best Regards,