Skip to content

Instantly share code, notes, and snippets.

@jakejscott
Created July 13, 2015 22:20
Show Gist options
  • Save jakejscott/a269cfc5f12c14f8adb2 to your computer and use it in GitHub Desktop.
Save jakejscott/a269cfc5f12c14f8adb2 to your computer and use it in GitHub Desktop.
Hash tag key generator
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