• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

ben-manes / caffeine / #5173

29 Dec 2025 05:27AM UTC coverage: 0.0% (-100.0%) from 100.0%
#5173

push

github

ben-manes
speed up development ci build

0 of 3838 branches covered (0.0%)

0 of 7869 relevant lines covered (0.0%)

0.0 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/caffeine/src/main/java/com/github/benmanes/caffeine/cache/Ticker.java
1
/*
2
 * Copyright 2014 Ben Manes. All Rights Reserved.
3
 *
4
 * Licensed under the Apache License, Version 2.0 (the "License");
5
 * you may not use this file except in compliance with the License.
6
 * You may obtain a copy of the License at
7
 *
8
 *     http://www.apache.org/licenses/LICENSE-2.0
9
 *
10
 * Unless required by applicable law or agreed to in writing, software
11
 * distributed under the License is distributed on an "AS IS" BASIS,
12
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
 * See the License for the specific language governing permissions and
14
 * limitations under the License.
15
 */
16
package com.github.benmanes.caffeine.cache;
17

18
import org.jspecify.annotations.NullMarked;
19

20
/**
21
 * A time source that returns a time value representing the number of nanoseconds elapsed since some
22
 * fixed but arbitrary point in time.
23
 *
24
 * @author ben.manes@gmail.com (Ben Manes)
25
 */
26
@NullMarked
27
@FunctionalInterface
28
public interface Ticker {
29

30
  /**
31
   * Returns the number of nanoseconds elapsed since this ticker's fixed point of reference.
32
   *
33
   * @return the number of nanoseconds elapsed since this ticker's fixed point of reference
34
   */
35
  long read();
36

37
  /**
38
   * Returns a ticker that reads the current time using {@link System#nanoTime}.
39
   *
40
   * @return a ticker that reads the current time using {@link System#nanoTime}
41
   */
42
  static Ticker systemTicker() {
43
    return SystemTicker.INSTANCE;
×
44
  }
45

46
  /**
47
   * Returns a ticker that always returns {@code 0}.
48
   *
49
   * @return a ticker that always returns {@code 0}
50
   */
51
  static Ticker disabledTicker() {
52
    return DisabledTicker.INSTANCE;
×
53
  }
54
}
55

56
enum SystemTicker implements Ticker {
×
57
  INSTANCE;
×
58

59
  @Override public long read() {
60
    return System.nanoTime();
×
61
  }
62
}
63

64
enum DisabledTicker implements Ticker {
×
65
  INSTANCE;
×
66

67
  @Override public long read() {
68
    return 0L;
×
69
  }
70
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc