From 813a3f5e4b050359391d06ea13efc98e1d11c0c3 Mon Sep 17 00:00:00 2001 From: Mikhail Chernyakov Date: Mon, 23 Dec 2019 09:25:18 +0100 Subject: [PATCH] rename --- README.md | 8 +++---- settings.gradle | 2 +- .../BackgroundMapCleaner.java | 12 +++++----- .../VariousTtlMap.java} | 4 ++-- .../VariousTtlMapImpl.java} | 24 +++++++++---------- .../applied/PrimitiveMapWrapper.java | 2 +- .../util/Preconditions.java | 2 +- .../util/ThreadFactoryBuilder.java | 2 +- .../util/ThreadUtil.java | 2 +- .../BackgroundMapCleanerTest.java | 8 +++---- .../VariousTtlMapImplTest.java} | 4 ++-- 11 files changed, 35 insertions(+), 35 deletions(-) rename src/main/java/com/github/mchernyakov/{variousttlcache => variousttlmap}/BackgroundMapCleaner.java (93%) rename src/main/java/com/github/mchernyakov/{variousttlcache/VariousTtlCache.java => variousttlmap/VariousTtlMap.java} (76%) rename src/main/java/com/github/mchernyakov/{variousttlcache/VariousTtlCacheImpl.java => variousttlmap/VariousTtlMapImpl.java} (85%) rename src/main/java/com/github/mchernyakov/{variousttlcache => variousttlmap}/applied/PrimitiveMapWrapper.java (95%) rename src/main/java/com/github/mchernyakov/{variousttlcache => variousttlmap}/util/Preconditions.java (89%) rename src/main/java/com/github/mchernyakov/{variousttlcache => variousttlmap}/util/ThreadFactoryBuilder.java (97%) rename src/main/java/com/github/mchernyakov/{variousttlcache => variousttlmap}/util/ThreadUtil.java (96%) rename src/test/java/com/github/mchernyakov/{variousttlcache => variousttlmap}/BackgroundMapCleanerTest.java (89%) rename src/test/java/com/github/mchernyakov/{variousttlcache/VariousTtlCacheImplTest.java => variousttlmap/VariousTtlMapImplTest.java} (80%) diff --git a/README.md b/README.md index edef014..69dc11e 100644 --- a/README.md +++ b/README.md @@ -1,10 +1,10 @@ -# Various time to live cache +# Various time to live map -[![Build Status](https://travis-ci.com/mchernyakov/various-ttl-cache.svg?branch=master)](https://travis-ci.com/mchernyakov/various-ttl-cache) +[![Build Status](https://travis-ci.com/mchernyakov/various-ttl-map.svg?branch=master)](https://travis-ci.com/mchernyakov/various-ttl-map) ## Description -Tiny library with various ttl cache. Based on Redis expire [algorithm](https://redis.io/commands/expire). +Tiny library with various ttl map. Based on Redis expire [algorithm](https://redis.io/commands/expire). The implementation contains two maps: 1) keys and values, @@ -39,7 +39,7 @@ Builder properties: #### In code ```java - VariousTtlCache map = VariousTtlCacheImpl.Builder.newBuilder() + VariousTtlMap map = VariousTtlMapImpl.Builder.newBuilder() .setDefaultTtl(2) .setCleaningPoolSize(2) .setNumCleaningAttemptsPerSession(250) diff --git a/settings.gradle b/settings.gradle index 77a5a63..f9b0488 100644 --- a/settings.gradle +++ b/settings.gradle @@ -1,2 +1,2 @@ -rootProject.name = 'various-ttl-cache' +rootProject.name = 'various-ttl-map' diff --git a/src/main/java/com/github/mchernyakov/variousttlcache/BackgroundMapCleaner.java b/src/main/java/com/github/mchernyakov/variousttlmap/BackgroundMapCleaner.java similarity index 93% rename from src/main/java/com/github/mchernyakov/variousttlcache/BackgroundMapCleaner.java rename to src/main/java/com/github/mchernyakov/variousttlmap/BackgroundMapCleaner.java index 3e63642..4993abb 100644 --- a/src/main/java/com/github/mchernyakov/variousttlcache/BackgroundMapCleaner.java +++ b/src/main/java/com/github/mchernyakov/variousttlmap/BackgroundMapCleaner.java @@ -1,7 +1,7 @@ -package com.github.mchernyakov.variousttlcache; +package com.github.mchernyakov.variousttlmap; -import com.github.mchernyakov.variousttlcache.util.Preconditions; -import com.github.mchernyakov.variousttlcache.util.ThreadUtil; +import com.github.mchernyakov.variousttlmap.util.Preconditions; +import com.github.mchernyakov.variousttlmap.util.ThreadUtil; import org.jetbrains.annotations.NotNull; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -32,14 +32,14 @@ class BackgroundMapCleaner { private static final int RED_LINE_PERCENT = 90; private final ScheduledExecutorService executorService; - private final VariousTtlCacheImpl map; + private final VariousTtlMapImpl map; private final long delayTime; private final int poolSize; private final int numKeyCheck; private final int percentWaterMark; - private BackgroundMapCleaner(VariousTtlCacheImpl variousTtlMap, Builder builder) { + private BackgroundMapCleaner(VariousTtlMapImpl variousTtlMap, Builder builder) { Preconditions.checkArgument(builder.poolSize > 0); Preconditions.checkArgument(builder.numKeyCheck > 0); Preconditions.checkArgument(builder.delayTime > 0); @@ -176,7 +176,7 @@ public Builder setPercentWaterMark(int percentWaterMark) { @SuppressWarnings("unchecked") public - BackgroundMapCleaner build(@NotNull VariousTtlCacheImpl map) { + BackgroundMapCleaner build(@NotNull VariousTtlMapImpl map) { Preconditions.checkNotNull(map); Builder self = (Builder) this; return new BackgroundMapCleaner<>(map, self); diff --git a/src/main/java/com/github/mchernyakov/variousttlcache/VariousTtlCache.java b/src/main/java/com/github/mchernyakov/variousttlmap/VariousTtlMap.java similarity index 76% rename from src/main/java/com/github/mchernyakov/variousttlcache/VariousTtlCache.java rename to src/main/java/com/github/mchernyakov/variousttlmap/VariousTtlMap.java index c639953..74e7b2f 100644 --- a/src/main/java/com/github/mchernyakov/variousttlcache/VariousTtlCache.java +++ b/src/main/java/com/github/mchernyakov/variousttlmap/VariousTtlMap.java @@ -1,9 +1,9 @@ -package com.github.mchernyakov.variousttlcache; +package com.github.mchernyakov.variousttlmap; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; -public interface VariousTtlCache { +public interface VariousTtlMap { @Nullable V get(K key); diff --git a/src/main/java/com/github/mchernyakov/variousttlcache/VariousTtlCacheImpl.java b/src/main/java/com/github/mchernyakov/variousttlmap/VariousTtlMapImpl.java similarity index 85% rename from src/main/java/com/github/mchernyakov/variousttlcache/VariousTtlCacheImpl.java rename to src/main/java/com/github/mchernyakov/variousttlmap/VariousTtlMapImpl.java index 4f62e41..2f31cdf 100644 --- a/src/main/java/com/github/mchernyakov/variousttlcache/VariousTtlCacheImpl.java +++ b/src/main/java/com/github/mchernyakov/variousttlmap/VariousTtlMapImpl.java @@ -1,7 +1,7 @@ -package com.github.mchernyakov.variousttlcache; +package com.github.mchernyakov.variousttlmap; -import com.github.mchernyakov.variousttlcache.applied.PrimitiveMapWrapper; -import com.github.mchernyakov.variousttlcache.util.Preconditions; +import com.github.mchernyakov.variousttlmap.applied.PrimitiveMapWrapper; +import com.github.mchernyakov.variousttlmap.util.Preconditions; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -10,20 +10,20 @@ import java.util.concurrent.TimeUnit; /** - * The Cache with various ttl for keys. + * The Map with various ttl for keys. *

* This implementation contains 2 maps : - * 1) store (key + value) {@link VariousTtlCacheImpl#store}, - * 2) map for ttl (key + ttl (when keys will be expired)) {@link VariousTtlCacheImpl#ttlMap}. + * 1) store (key + value) {@link VariousTtlMapImpl#store}, + * 2) map for ttl (key + ttl (when keys will be expired)) {@link VariousTtlMapImpl#ttlMap}. *

* This implementation has two variants of cleaning: - * 1) passive via {@link VariousTtlCacheImpl#get(K)}, + * 1) passive via {@link VariousTtlMapImpl#get(K)}, * 2) active via {@link BackgroundMapCleaner}. * * @param key * @param value */ -public class VariousTtlCacheImpl implements VariousTtlCache { +public class VariousTtlMapImpl implements VariousTtlMap { private final ConcurrentHashMap store; private final PrimitiveMapWrapper ttlMap; @@ -32,7 +32,7 @@ public class VariousTtlCacheImpl implements VariousTtlCache { private final long defaultTtl; private final TimeUnit timeUnit = TimeUnit.SECONDS; - private VariousTtlCacheImpl(Builder builder) { + private VariousTtlMapImpl(Builder builder) { Preconditions.checkArgument(builder.defaultTtl > 0); defaultTtl = timeUnit.toNanos(builder.defaultTtl); @@ -112,7 +112,7 @@ public void shutdown() { @Override public String toString() { - return "VariousTtlCacheImpl{" + + return "VariousTtlMapImpl{" + "store=" + store + ", ttlMap=" + ttlMap + ", mapCleaner=" + mapCleaner + @@ -161,9 +161,9 @@ public Builder setDelayMillis(int delayMillis) { } @SuppressWarnings("unchecked") - public VariousTtlCacheImpl build() { + public VariousTtlMapImpl build() { Builder self = (Builder) this; - return new VariousTtlCacheImpl<>(self); + return new VariousTtlMapImpl<>(self); } } } diff --git a/src/main/java/com/github/mchernyakov/variousttlcache/applied/PrimitiveMapWrapper.java b/src/main/java/com/github/mchernyakov/variousttlmap/applied/PrimitiveMapWrapper.java similarity index 95% rename from src/main/java/com/github/mchernyakov/variousttlcache/applied/PrimitiveMapWrapper.java rename to src/main/java/com/github/mchernyakov/variousttlmap/applied/PrimitiveMapWrapper.java index 88e721a..e933f58 100644 --- a/src/main/java/com/github/mchernyakov/variousttlcache/applied/PrimitiveMapWrapper.java +++ b/src/main/java/com/github/mchernyakov/variousttlmap/applied/PrimitiveMapWrapper.java @@ -1,4 +1,4 @@ -package com.github.mchernyakov.variousttlcache.applied; +package com.github.mchernyakov.variousttlmap.applied; import it.unimi.dsi.fastutil.ints.Int2LongOpenHashMap; diff --git a/src/main/java/com/github/mchernyakov/variousttlcache/util/Preconditions.java b/src/main/java/com/github/mchernyakov/variousttlmap/util/Preconditions.java similarity index 89% rename from src/main/java/com/github/mchernyakov/variousttlcache/util/Preconditions.java rename to src/main/java/com/github/mchernyakov/variousttlmap/util/Preconditions.java index 933e637..7f2dc16 100644 --- a/src/main/java/com/github/mchernyakov/variousttlcache/util/Preconditions.java +++ b/src/main/java/com/github/mchernyakov/variousttlmap/util/Preconditions.java @@ -1,4 +1,4 @@ -package com.github.mchernyakov.variousttlcache.util; +package com.github.mchernyakov.variousttlmap.util; import org.jetbrains.annotations.NotNull; diff --git a/src/main/java/com/github/mchernyakov/variousttlcache/util/ThreadFactoryBuilder.java b/src/main/java/com/github/mchernyakov/variousttlmap/util/ThreadFactoryBuilder.java similarity index 97% rename from src/main/java/com/github/mchernyakov/variousttlcache/util/ThreadFactoryBuilder.java rename to src/main/java/com/github/mchernyakov/variousttlmap/util/ThreadFactoryBuilder.java index 8a6bc5a..381c29c 100644 --- a/src/main/java/com/github/mchernyakov/variousttlcache/util/ThreadFactoryBuilder.java +++ b/src/main/java/com/github/mchernyakov/variousttlmap/util/ThreadFactoryBuilder.java @@ -1,4 +1,4 @@ -package com.github.mchernyakov.variousttlcache.util; +package com.github.mchernyakov.variousttlmap.util; import java.util.Locale; import java.util.concurrent.Executors; diff --git a/src/main/java/com/github/mchernyakov/variousttlcache/util/ThreadUtil.java b/src/main/java/com/github/mchernyakov/variousttlmap/util/ThreadUtil.java similarity index 96% rename from src/main/java/com/github/mchernyakov/variousttlcache/util/ThreadUtil.java rename to src/main/java/com/github/mchernyakov/variousttlmap/util/ThreadUtil.java index 8ab49cd..c21c646 100644 --- a/src/main/java/com/github/mchernyakov/variousttlcache/util/ThreadUtil.java +++ b/src/main/java/com/github/mchernyakov/variousttlmap/util/ThreadUtil.java @@ -1,4 +1,4 @@ -package com.github.mchernyakov.variousttlcache.util; +package com.github.mchernyakov.variousttlmap.util; import java.util.concurrent.ExecutorService; import java.util.concurrent.ThreadFactory; diff --git a/src/test/java/com/github/mchernyakov/variousttlcache/BackgroundMapCleanerTest.java b/src/test/java/com/github/mchernyakov/variousttlmap/BackgroundMapCleanerTest.java similarity index 89% rename from src/test/java/com/github/mchernyakov/variousttlcache/BackgroundMapCleanerTest.java rename to src/test/java/com/github/mchernyakov/variousttlmap/BackgroundMapCleanerTest.java index 330ec34..4dac901 100644 --- a/src/test/java/com/github/mchernyakov/variousttlcache/BackgroundMapCleanerTest.java +++ b/src/test/java/com/github/mchernyakov/variousttlmap/BackgroundMapCleanerTest.java @@ -1,4 +1,4 @@ -package com.github.mchernyakov.variousttlcache; +package com.github.mchernyakov.variousttlmap; import org.junit.After; import org.junit.Assert; @@ -9,12 +9,12 @@ public class BackgroundMapCleanerTest { - private VariousTtlCacheImpl mapClassic; + private VariousTtlMapImpl mapClassic; private BackgroundMapCleaner mapCleaner; @Before public void setUp() throws Exception { - mapClassic = VariousTtlCacheImpl.Builder.newBuilder() + mapClassic = VariousTtlMapImpl.Builder.newBuilder() .setDefaultTtl(2) .setCleaningPoolSize(1) .setNumCleaningAttemptsPerSession(20) @@ -54,7 +54,7 @@ public void basicTest1() throws Exception { @Test public void basicTest2() throws Exception { - VariousTtlCache mapClassic = VariousTtlCacheImpl.Builder.newBuilder() + VariousTtlMap mapClassic = VariousTtlMapImpl.Builder.newBuilder() .setDefaultTtl(2) .setCleaningPoolSize(2) .setNumCleaningAttemptsPerSession(250) diff --git a/src/test/java/com/github/mchernyakov/variousttlcache/VariousTtlCacheImplTest.java b/src/test/java/com/github/mchernyakov/variousttlmap/VariousTtlMapImplTest.java similarity index 80% rename from src/test/java/com/github/mchernyakov/variousttlcache/VariousTtlCacheImplTest.java rename to src/test/java/com/github/mchernyakov/variousttlmap/VariousTtlMapImplTest.java index d440bdc..a499a1b 100644 --- a/src/test/java/com/github/mchernyakov/variousttlcache/VariousTtlCacheImplTest.java +++ b/src/test/java/com/github/mchernyakov/variousttlmap/VariousTtlMapImplTest.java @@ -1,11 +1,11 @@ -package com.github.mchernyakov.variousttlcache; +package com.github.mchernyakov.variousttlmap; import org.junit.Test; import java.util.HashMap; import java.util.Map; -public class VariousTtlCacheImplTest { +public class VariousTtlMapImplTest { @Test(expected = Exception.class) public void conditionTest() throws Exception {