package org.sagebionetworks.bridge.redis;

/**
 * A Redis key concatenates the original key with a list of domains to form a compound key
 * where different parts are separated by ':'.
 * <p>
 * Examples:
 * <p>
 * <code>
 *    {id}:id:user
 *    {session}:session:user
 *    {email}:email:user
 * </code>
 * <p>
 * where keys are put into different "user" domains such as keys across domains are
 * allowed to have duplicates whereas within each domain they are unique.
 */
public interface RedisKey {

    /** For internal locking. */
    RedisKey LOCK = new SimpleKey("lock");

    /** User sessions. */
    RedisKey SESSION = new SimpleKey("session");
    
    /** Study */
    RedisKey STUDY = new SimpleKey("study");

    /** User health code. */
    RedisKey HEALTH_CODE = new SimpleKey("health-code");

    /** User (email). */
    RedisKey USER = new SimpleKey("user");
    
    /** Health code lock. */
    RedisKey HEALTH_CODE_LOCK = new CompoundKey((SimpleKey)HEALTH_CODE, (SimpleKey)LOCK);
    
    /** Lock on user account. */
    RedisKey USER_LOCK = new CompoundKey((SimpleKey)USER, (SimpleKey)LOCK);

    /** Number of participants in a study */
    RedisKey NUM_OF_PARTICIPANTS = new SimpleKey("num-of-participants");
    
    /** A cached JSON response. */
    RedisKey VIEW = new SimpleKey("view");
    
    String SEPARATOR = ":";

    /**
     * The suffix that is appended to the original key to obtain the Redis key.
     */
    String getSuffix();

    /**
     * The compound Redis key.
     */
    String getRedisKey(String key);

    /**
     * The original key.
     */
    String getOriginalKey(String redisKey);
}

@@ -313,26 +313,36 @@
 %0A * 
-where keys are put
+Note that keys are separated
  int
@@ -356,15 +356,8 @@
 rent
- %22user%22
  dom
@@ -365,112 +365,26 @@
 ins 
-such as keys across domains are%0A * allowed to have duplicates whereas within each domain they are unique
+to avoid conflicts
 .%0A *
@@ -562,29 +562,25 @@
 %22session%22);%0A
-    
 %0A
+
     /** Stud
@@ -781,29 +781,25 @@
 ey(%22user%22);%0A
-    
 %0A
+
     /** Heal
@@ -905,21 +905,17 @@
 )LOCK);%0A
-    
 %0A
+
     /** 
@@ -1130,29 +1130,25 @@
 icipants%22);%0A
-    
 %0A
+
     /** A ca
@@ -1213,20 +1213,16 @@
 view%22);%0A
-    
 %0A    Str

Remove trailing whitespace