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

alibaba / jetcache / #405

16 Apr 2024 05:58AM UTC coverage: 0.0% (-88.9%) from 88.866%
#405

push

areyouok
add encoding to fix coverage report

0 of 5353 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
/jetcache-core/src/main/java/com/alicp/jetcache/embedded/Cleaner.java
1
package com.alicp.jetcache.embedded;
2

3
import com.alicp.jetcache.support.JetCacheExecutor;
4

5
import java.lang.ref.WeakReference;
6
import java.util.Iterator;
7
import java.util.LinkedList;
8
import java.util.concurrent.ScheduledExecutorService;
9
import java.util.concurrent.TimeUnit;
10
import java.util.concurrent.locks.ReentrantLock;
11

12
/**
13
 * Created on 2017/2/28.
14
 *
15
 * @author huangli
16
 */
17
class Cleaner {
×
18

19
    static LinkedList<WeakReference<LinkedHashMapCache>> linkedHashMapCaches = new LinkedList<>();
×
20
    private static final ReentrantLock reentrantLock = new  ReentrantLock();
×
21

22
    static {
23
        ScheduledExecutorService executorService = JetCacheExecutor.defaultExecutor();
×
24
        executorService.scheduleWithFixedDelay(() -> run(), 60, 60, TimeUnit.SECONDS);
×
25
    }
×
26

27
    static void add(LinkedHashMapCache cache) {
28
        reentrantLock.lock();
×
29
        try{
30
            linkedHashMapCaches.add(new WeakReference<>(cache));
×
31
        }finally {
32
            reentrantLock.unlock();
×
33
        }
34
    }
×
35

36
    static void run() {
37
        reentrantLock.lock();
×
38
        try{
39
            Iterator<WeakReference<LinkedHashMapCache>> it = linkedHashMapCaches.iterator();
×
40
            while (it.hasNext()) {
×
41
                WeakReference<LinkedHashMapCache> ref = it.next();
×
42
                LinkedHashMapCache c = ref.get();
×
43
                if (c == null) {
×
44
                    it.remove();
×
45
                } else {
46
                    c.cleanExpiredEntry();
×
47
                }
48
            }
×
49
        }finally {
50
            reentrantLock.unlock();
×
51
        }
52
    }
×
53

54
}
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

© 2025 Coveralls, Inc