Prepared statement caching issue in Cassandra Csharp driver

后端 未结 2 911
佛祖请我去吃肉
佛祖请我去吃肉 2021-01-20 10:28

I believe I have found a bug with the logic of how a prepared statement is cached in the StatementFactory in the Cassandra csharp driver (version 2.7.3). Here is the use cas

相关标签:
2条回答
  • 2021-01-20 11:13

    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

    0 讨论(0)
  • 2021-01-20 11:25

    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);
    
    0 讨论(0)
提交回复
热议问题