Skip to content

Commit

Permalink
PLT-191: update prefix through config
Browse files Browse the repository at this point in the history
  • Loading branch information
n5nk committed Nov 30, 2023
1 parent 90606b4 commit e63b26e
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 5 deletions.
1 change: 1 addition & 0 deletions docs/configs/janusgraph-cfg.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ Configuration options that modify JanusGraph's caching behavior

| Name | Description | Datatype | Default Value | Mutability |
| ---- | ---- | ---- | ---- | ---- |
| cache.cache-keyspace-prefix | Set prefix for keyspace created in redis. | String | janusgraph | MASKABLE |
| cache.cache-type | Enable or disable Redis cache (redis/inmemory) | String | inmemory | MASKABLE |
| cache.db-cache | Whether to enable JanusGraph's database-level cache, which is shared across all transactions. Enabling this option speeds up traversals by holding hot graph elements in memory, but also increases the likelihood of reading stale data. Disabling it forces each transaction to independently fetch graph elements from storage before reading/writing them. | Boolean | false | MASKABLE |
| cache.db-cache-clean-wait | How long, in milliseconds, database-level cache will keep entries after flushing them. This option is only useful on distributed storage backends that are capable of acknowledging writes without necessarily making them immediately visible. | Integer | 50 | GLOBAL_OFFLINE |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

package org.janusgraph.diskstorage.keycolumnvalue.cache;

import static org.janusgraph.graphdb.configuration.GraphDatabaseConfiguration.CACHE_KEYSPACE_PREFIX;

import com.google.common.base.Preconditions;
import com.google.common.cache.CacheLoader;
Expand Down Expand Up @@ -47,7 +48,6 @@
import static org.janusgraph.util.datastructures.ByteSize.OBJECT_HEADER;
import static org.janusgraph.util.datastructures.ByteSize.OBJECT_REFERENCE;
import static org.janusgraph.util.datastructures.ByteSize.STATICARRAYBUFFER_RAW_SIZE;

/**
* @author Matthias Broecheler ([email protected])
*/
Expand All @@ -59,8 +59,7 @@ public class ExpirationKCVSRedisCache extends KCVSCache {

private static final int INVALIDATE_KEY_FRACTION_PENALTY = 1000;
private static final int PENALTY_THRESHOLD = 5;
public static final String REDIS_CACHE_PREFIX = "redis-cache-";
public static final String REDIS_INDEX_CACHE_PREFIX = "redis-index-cache-";
public static final String REDIS_INDEX_CACHE_PREFIX = "-index-";

private volatile CountDownLatch penaltyCountdown;

Expand All @@ -86,8 +85,8 @@ public ExpirationKCVSRedisCache(final KeyColumnValueStore store, String metricsN
this.invalidationGracePeriodMS = invalidationGracePeriodMS;

redissonClient = RedissonCache.getRedissonClient(configuration);
redisCache = redissonClient.getLocalCachedMap(REDIS_CACHE_PREFIX + metricsName, LocalCachedMapOptions.defaults());
redisIndexKeys = redissonClient.getLocalCachedMap(REDIS_INDEX_CACHE_PREFIX + metricsName, LocalCachedMapOptions.defaults());
redisCache = redissonClient.getLocalCachedMap(String.join("-",configuration.get(CACHE_KEYSPACE_PREFIX), metricsName), LocalCachedMapOptions.defaults());
redisIndexKeys = redissonClient.getLocalCachedMap(String.join("-", configuration.get(CACHE_KEYSPACE_PREFIX) , REDIS_INDEX_CACHE_PREFIX , metricsName), LocalCachedMapOptions.defaults());
expiredKeys = new ConcurrentHashMap<>(50, 0.75f, concurrencyLevel);
penaltyCountdown = new CountDownLatch(PENALTY_THRESHOLD);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -359,6 +359,10 @@ public boolean apply(@Nullable String s) {
"Enable or disable Redis cache (redis/inmemory)",
ConfigOption.Type.MASKABLE, "inmemory");

public static final ConfigOption<String> CACHE_KEYSPACE_PREFIX = new ConfigOption<>(CACHE_NS,"cache-keyspace-prefix",
"Set prefix for keyspace created in redis.",
ConfigOption.Type.MASKABLE, "janusgraph");

public static final ConfigOption<String> REDIS_CACHE_SENTINEL_URLS = new ConfigOption<>(CACHE_NS,"redis-cache-sentinel-urls",
"csv values for multiple redis sentinel host:port urls.",
ConfigOption.Type.MASKABLE, "localhost:26379");
Expand Down

0 comments on commit e63b26e

Please sign in to comment.