Skip to content

Commit

Permalink
Merge branch 'pr-4867'
Browse files Browse the repository at this point in the history
  • Loading branch information
mmoayyed committed May 26, 2020
2 parents fce5984 + 0defa43 commit 503b161
Showing 1 changed file with 10 additions and 13 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package org.apereo.cas.ticket.registry;

import org.apereo.cas.ticket.ExpirationPolicy;
import org.apereo.cas.ticket.Ticket;

import lombok.RequiredArgsConstructor;
Expand Down Expand Up @@ -40,12 +41,9 @@ public void addTicket(final Ticket ticketToAdd) {
? expirationPolicy.getTimeToLive()
: expirationPolicy.getTimeToIdle();

LOGGER.debug("Adding ticket [{}] to cache store to live [{}] seconds and stay idle for [{}]",
ticketToAdd.getId(), expirationPolicy.getTimeToLive(), idleTime);

this.cache.put(ticket.getId(), ticket,
expirationPolicy.getTimeToLive(), TimeUnit.SECONDS,
idleTime, TimeUnit.SECONDS);
val ttl = getTimeToLive(expirationPolicy);
LOGGER.debug("Adding ticket [{}] to cache store to live [{}] seconds and stay idle for [{}]", ticketToAdd.getId(), ttl, idleTime);
this.cache.put(ticket.getId(), ticket, ttl, TimeUnit.SECONDS, idleTime, TimeUnit.SECONDS);
}

@Override
Expand Down Expand Up @@ -73,15 +71,14 @@ public long deleteAll() {
this.cache.clear();
return size;
}

/**
* Retrieve all tickets from the registry.
*
* @return collection of tickets currently stored in the registry. Tickets
* might or might not be valid i.e. expired.
*/

@Override
public Collection<? extends Ticket> getTickets() {
return decodeTickets(this.cache.values());
}

private static Long getTimeToLive(final ExpirationPolicy expirationPolicy) {
val timeToLive = expirationPolicy.getTimeToLive();
return Long.MAX_VALUE == timeToLive ? Long.valueOf(Integer.MAX_VALUE) : timeToLive;
}
}

0 comments on commit 503b161

Please sign in to comment.