ServiceStack Redis what is an urn

What does "urn:" mean?

I play with the ServiceStack Redis example. This is like a naming convention, many keys in db, starting with "urn:".

By calling somePoco.CreateUrn(); β†’ "urn:somePoco:123" It creates a key in the database.

And the advantage of this is that RedisTypedClient can arrange it in the following code: for example

 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\"}" 

Do I understand correctly? Or am I even close?

+6
source share
1 answer

It stands for Uniform Resource Name .

Since Redis does not have a concept for namespaces or schemas, we use a fully qualified key with the format:

 urn:{TypeName}:{Id} 

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

The RedisAdmin user interface also uses this convention to provide a hierarchical tree structure for accessing your data, even though it does not have this concept in Redis.

+9
source

Source: https://habr.com/ru/post/924133/


All Articles