How to clear all type X instances in ServiceStack Redis Client

I want to remove all instance of X from Redis Db for testing. But I could not find redisClient.As (). CLEAR () method? How can I delete all instances of X?

I can add X instances using

var client=new PooledRedisClientManager(ConfigurationManager.AppSettings["RedisServer"]).GetClient(); X x=new X(); client.As<X>().Store(x); 

all x instances are added to Db as urn: X: x.id pattern.

+1
source share
3 answers

IRedisTypedClient implements a common IBasicPersistenceProvider <T> , which has a DeleteAll() method. So what you need is just:

 client.As<T>().DeleteAll(); 

For smaller removal options, you also have:

 client.As<T>().DeleteById(id); client.As<T>().DeleteByIds(ids); 
+1
source

If you use the RedisNativeClient class, you have this method to delete a specific key:

  public int Del(string key) 

if you want to delete all the keys that you can call Del with * as a key

and you have these methods:

  public void FlushDb() public void FlushAll() 

if you are using the RedisClient class, you have this method:

  public bool Remove(string key) // Again i guess you can use the * for delete all keys 
+1
source

client.As () DeleteAll () ;.

I think the name β€œDelete” refers to a relationship.

User.Cars.Remove ("Red Car")

If you want to delete the "Delete" object :)

Delete ("Red Car")

This does not work. I get a strange {"wrong number of arguments for the" del "command, sPort: 19570, LastCommand:"}.

0
source

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


All Articles