Skip to content

[api] Delay always uses the expireAfterWrite duration time instead of the custom duration in the markDelay method. #1153

@Jakubk15

Description

@Jakubk15
public Delay(Supplier<Duration> delayProvider) {
        this.delaySettings = delayProvider;

        this.delays = CacheBuilder.newBuilder()
            .expireAfterWrite(delayProvider.get())
            .build();
    }

public void markDelay(T key, Duration delay) {
        this.delays.put(key, Instant.now().plus(delay));
    }

Problematic example:

Delay<String> delay = new Delay<>(() -> Duration.ofSeconds(10)); // cache expiry: 10s

// Mark delay for 60s
delay.markDelay("player1", Duration.ofSeconds(60));

// After 10s: entry physically disappears from cache
// After 15s: hasDelay("player1") will return FALSE, although theoretically it should be true for 45 more seconds.

Metadata

Metadata

Assignees

Labels

Type

Projects

Status

👀 In review

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions