Prepared statement caching issue in Cassandra Csharp driver

后端 未结 2 912
佛祖请我去吃肉
佛祖请我去吃肉 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: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()
          .TableName("foo")
          .KeyspaceName("ks1"),
       new Map()
          .TableName("bar")
          .KeyspaceName("ks2"));
    
    ISession session = cluster.Connect();
    IMapper mapper = new Mapper(session);
    

提交回复
热议问题