Created
July 13, 2015 22:20
-
-
Save jakejscott/a269cfc5f12c14f8adb2 to your computer and use it in GitHub Desktop.
Hash tag key generator
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
namespace Microsoft.Web.Redis | |
{ | |
internal class KeyGenerator | |
{ | |
private string id; | |
public string DataKey | |
{ | |
get; | |
private set; | |
} | |
public string InternalKey | |
{ | |
get; | |
private set; | |
} | |
public string LockKey | |
{ | |
get; | |
private set; | |
} | |
public KeyGenerator(string id, string applicationName) | |
{ | |
SetKeys(id, applicationName); | |
} | |
public void RegenerateKeyStringIfIdModified(string id, string applicationName) | |
{ | |
if (!id.Equals(this.id)) | |
{ | |
SetKeys(id, applicationName); | |
} | |
} | |
private void SetKeys(string id, string applicationName) | |
{ | |
this.id = id; | |
this.DataKey = string.Concat("{", applicationName, "_", id, "}", "_Data"); | |
this.LockKey = string.Concat("{", applicationName, "_", id, "}", "_Write_Lock"); | |
this.InternalKey = string.Concat("{", applicationName, "_", id, "}", "_Internal"); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment