Prepared statement caching issue in Cassandra Csharp driver

北战南征 提交于 2019-12-01 21:50:25

As a simple workaround, I am skipping the cache by using the DoNotPrepare

await _mapper.DeleteAsync<Foo>(Cql.New("WHERE id = ?", key).WithOptions(opt => opt.DoNotPrepare()));

I also found an open issue with Datastax

There is an open ticket to fix this behaviour.

As a workaround, you can use a different MappingConfiguration instances when creating the Mapper:

ISession session1 = cluster.Connect("ks1");
ISession session2 = cluster.Connect("ks2");

IMapper mapper1 = new Mapper(session1, new MappingConfiguration());
IMapper mapper2 = new Mapper(session2, new MappingConfiguration());

Or, you can reuse a single ISession instance and fully-qualify your queries to include the keyspace.

MappingConfiguration.Global.Define(
   new Map<Foo>()
      .TableName("foo")
      .KeyspaceName("ks1"),
   new Map<Bar>()
      .TableName("bar")
      .KeyspaceName("ks2"));

ISession session = cluster.Connect();
IMapper mapper = new Mapper(session);
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!