int getMemcachedExpirationTimeToSet() {

        /* SRV.13.4 ("Deployment Descriptor"): If the timeout is 0 or less, the container
         * ensures the default behaviour of sessions is never to time out.
         */
        if ( maxInactiveInterval <= 0 ) {
            return 0;
        }

        if ( !_sticky ) {
            return 2 * maxInactiveInterval;
        }

        final long timeIdleInMillis = System.currentTimeMillis() - getThisAccessedTimeInternal();
        /* rounding is just for tests, as they are using actually seconds for testing.
         * with a default setup 1 second difference wouldn't matter...
         */
        final int timeIdle = Math.round( (float)timeIdleInMillis / 1000L );
        final int expirationTime = getMaxInactiveInterval() - timeIdle;
        final int processExpiresOffset = getManager().getProcessExpiresFrequency() * getManager().getContext().getBackgroundProcessorDelay();
        return expirationTime + processExpiresOffset;
    }
int getMemcachedExpirationTimeToSet ( ) { if ( maxInactiveInterval <= 0 ) { return 0 ; } if ( ! _sticky ) { return 2 * maxInactiveInterval ; } final long timeIdleInMillis = System . currentTimeMillis ( ) - getThisAccessedTimeInternal ( ) ; final int timeIdle = Math . round ( ( float ) timeIdleInMillis / 1000L ) ; final int expirationTime = getMaxInactiveInterval ( ) - timeIdle ; final int processExpiresOffset = getManager ( ) . getProcessExpiresFrequency ( ) * getManager ( ) . getContext ( ) . getBackgroundProcessorDelay ( ) ; return expirationTime + processExpiresOffset ; }
Calculates the expiration time that must be sent to memcached,
based on the sessions maxInactiveInterval and the time the session
is already idle (based on thisAccessedTime).
<p>
Calculating this time instead of just using maxInactiveInterval is
important for the update of the expiration time: if we would just use
maxInactiveInterval, the session would exist longer in memcached than it would
be valid in tomcat.
</p>

@return the expiration time in seconds