Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>You have a couple options here. </p> <p><strong>1)</strong> You could let ServiceStack take care of this for you by using the high level Redis API. </p> <pre><code>public class Poco { public int Id { get; set; } public string Name { get; set; } public string Description { get; set; } } ... // Client var client = new RedisClient("localhost", 6379); // This will store the object for you in a Redis hash. client.StoreAsHash(new Poco { Id = 1, Name = "Test Name", Description = "Test Description" }); // This will fetch it back for you. var result = client.GetFromHash&lt;Poco&gt;(1); </code></pre> <p>This approach will disconnect you from having to deal directly with the hashing particulars. ServiceStack will figure out everything for you and stuff the object you send it into a hash automatically. If you want to update that object, just send it a new one with the same ID.</p> <p>The flip-side of this is that you're giving up control of how your data is stored in Redis for an easier programming experience.</p> <p><strong>2)</strong> You handle all of the stuff yourself. There is no <em>SetAllEntriesToHash</em> function pre-built.</p> <pre><code>// Client var client = new RedisClient("localhost", 6379); // Clear all existing keys var keysToClear = new Dictionary&lt;string,string&gt;(); client.GetHashKeys("xxxxx").ForEach(k =&gt; keysToClear.Add(k, "")); client.SetRangeInHash("xxxxx", keysToClear); // Save new key/values. client.SetRangeInHash("xxxxx", new List&lt;KeyValuePair&lt;string, string&gt;&gt; { new KeyValuePair&lt;string, string&gt;("1", "value 1"), new KeyValuePair&lt;string, string&gt;("2", "value 2"), new KeyValuePair&lt;string, string&gt;("3", "value 3"), }); </code></pre> <p>Alternatively, it may be easier just to delete and recreate the hash.</p> <p>I would also like to draw your attention to <strong>RedisNativeClient</strong>. It allows you to run Redis commands that directly map to <a href="http://redis.io/commands" rel="nofollow">http://redis.io/commands</a>.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload