2 Replies Latest reply on Mar 30, 2016 12:10 PM by william.burns

    Scheduling of the cache cleaning.

    n.dobryukha

      I use Infinispan server 8.2.0.Final

      Is there any way to clean cache by scheduler. For example everyday at 9.

        • 1. Re: Scheduling of the cache cleaning.
          nadirx

          We don't have a built-in scheduler, but you could use the following crontab:

           

          0 9 * * * /path/to/server/bin/ispn-cli.sh -c --command='/host=master/server=server-one/subsystem=datagrid-infinispan/cache-container=clustered/distributed-cache=default:clear-cache()'

           

          Make sure the crontab is for the same user who is running the server, so that "silent" connection is possible.

          • 2. Re: Scheduling of the cache cleaning.
            william.burns

            Not quite sure what you mean by cleaning.  But if you mean checking for expired entries, you can configure it to run after a delay via configuration [1].  Note there is also an xml definition available for this.

             

            Or if you really want it to occur at a given time, you can create a single thread scheduled executor manually [2] and then submit a task that does the following

             

            cache.getAdvancedCache().getExpirationManager().processExpiration();
            

             

            and schedule that to run at a fixed rate, such as every day.

             

            [1] ExpirationConfigurationBuilder (Infinispan JavaDoc 8.1.2.Final API)

            [2] Executors (Java Platform SE 7 )