Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ServiceStack Redis what is urn

What does "urn:" stand for?

I am playing with the ServiceStack Redis example. It seems like a naming convention, many keys in the db starting with "urn:".

By calling somePoco.CreateUrn(); --> "urn:somePoco:123" It creates the key in the database.

And the advantage of it is that RedisTypedClient can regonize it in the following code: e.g.

var redisSomePoco = redis.As<SomePoco>();
var somePoco = redisSomePoco.GetById("123"); //it knows I want value of key "urn:somePoco:123"
redisSomePoco.Store(somePoco); //it knows how to store my poco value in key "urn:somePoco:123"
//"{\"Id\":123,\"DisplayName\":\"Michael\"}"

Is my understanding correct? Or am I even close?

like image 481
Tom Avatar asked Aug 30 '12 00:08

Tom


1 Answers

It stands for Uniform Resource Name.

Since there is no concept of namespaces or schemas in Redis we use a fully-qualified key with the format of:

urn:{TypeName}:{Id}

To uniquely store and identify any POCO instance stored in Redis using the Typed API of ServiceStack's C# RedisClient.

The RedisAdmin UI also takes advantage of this convention to provide a hierarchical tree-like structure to access your data despite their being no concept of such in Redis.

like image 164
mythz Avatar answered Oct 23 '22 21:10

mythz