org.apache.commons.collections4.map.PassiveExpiringMap Java Examples
The following examples show how to use
org.apache.commons.collections4.map.PassiveExpiringMap.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: MQTTSession.java From vertx-mqtt-broker with Apache License 2.0 | 6 votes |
public MQTTSession(Vertx vertx, ConfigParser config) { this.vertx = vertx; this.decoder = new MQTTDecoder(); this.encoder = new MQTTEncoder(); this.securityEnabled = config.isSecurityEnabled(); this.retainSupport = config.isRetainSupport(); this.subscriptions = new LinkedHashMap<>(); this.qosUtils = new QOSUtils(); PassiveExpiringMap.ConstantTimeToLiveExpirationPolicy<String, List<Subscription>> expirePeriod = new PassiveExpiringMap.ConstantTimeToLiveExpirationPolicy<>( 30, TimeUnit.MINUTES); this.matchingSubscriptionsCache = new PassiveExpiringMap<>( expirePeriod, new HashMap<>() ); this.topicsManager = new MQTTTopicsManagerOptimized(); this.storeManager = new StoreManager(this.vertx); this.authenticatorAddress = config.getAuthenticatorAddress(); this.queue = new LinkedList<>(); }
Example #2
Source File: CachingTargetResolver.java From promregator with Apache License 2.0 | 5 votes |
@PostConstruct public void setupCache() { /* Note that this cannot be done during construction as * this.timeoutCacheResolverLevel isn't available there, yet. */ this.targetResolutionCache = new PassiveExpiringMap<>(this.timeoutCacheResolverLevel, TimeUnit.SECONDS); }
Example #3
Source File: StoreVerticle.java From vertx-mqtt-broker with Apache License 2.0 | 5 votes |
@Override public void start() throws Exception { PassiveExpiringMap.ConstantTimeToLiveExpirationPolicy<String, Map<String, byte[]>> expirePeriod = new PassiveExpiringMap.ConstantTimeToLiveExpirationPolicy<>( 1, TimeUnit.DAYS); this.db = new PassiveExpiringMap<>( expirePeriod, new LinkedHashMap<>() ); this.topicsManager = new MQTTTopicsManagerOptimized(); MessageConsumer<JsonObject> consumer = vertx.eventBus().consumer(ADDRESS); consumer.handler(message -> { JsonObject request = message.body(); MultiMap headers = message.headers(); if (headers == null || !headers.contains("command")) { message.reply(new JsonObject().put("error", "Invalid message: missing 'command' header")); } JsonObject response = new JsonObject(); String command = headers.get("command"); switch (command) { case "saveRetainMessage": response = saveRetainMessage(request); break; case "getRetainedMessagesByTopicFilter": response = getRetainedMessagesByTopicFilter(request); break; case "deleteRetainMessage": response = deleteRetainMessage(request); break; default: response = doDefault(request); break; } // System.out.println("instance => "+ this + "db.size => "+ db.size()); message.reply(response); }); }
Example #4
Source File: MemoryAccessTokenRepository.java From james-project with Apache License 2.0 | 4 votes |
@Inject public MemoryAccessTokenRepository(@Named(TOKEN_EXPIRATION_IN_MS) long durationInMilliseconds) { tokensExpirationDates = new PassiveExpiringMap<>(durationInMilliseconds); }
Example #5
Source File: EphemeralAutoRegisterKeyService.java From gocd with Apache License 2.0 | 4 votes |
@Autowired public EphemeralAutoRegisterKeyService(SystemEnvironment systemEnvironment) { keyStore = new PassiveExpiringMap<>(systemEnvironment.getEphemeralAutoRegisterKeyExpiryInMillis(), MILLISECONDS); }