Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/.net/20.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# Apache Ignite.Net(2.8.1)条目ICacheEntryProcessor写入失败_C#_.net_Ignite - Fatal编程技术网

C# Apache Ignite.Net(2.8.1)条目ICacheEntryProcessor写入失败

C# Apache Ignite.Net(2.8.1)条目ICacheEntryProcessor写入失败,c#,.net,ignite,C#,.net,Ignite,我想验证我的理解是否正确。。在阅读了有关ICacheEntryProcessor的文档后,它说如果我们想要更新缓存条目中的字段,我们将实现这个类,并使用缓存上的Invoke来原子地更新缓存记录中的字段 当我实现上述方法时,记录似乎没有被更新。process方法中没有抛出异常 这是我的实现 public class UserConnectionUpdateProcessor : ICacheEntryProcessor<string, User, UserConnection, bool&g

我想验证我的理解是否正确。。在阅读了有关ICacheEntryProcessor的文档后,它说如果我们想要更新缓存条目中的字段,我们将实现这个类,并使用缓存上的Invoke来原子地更新缓存记录中的字段

当我实现上述方法时,记录似乎没有被更新。process方法中没有抛出异常

这是我的实现

public class UserConnectionUpdateProcessor : ICacheEntryProcessor<string, User, UserConnection, bool>
    {
        /// <summary>
        /// Processes the update
        /// </summary>
        /// <param name="entry"></param>
        /// <param name="arg"></param>
        /// <returns></returns>
        public bool Process(IMutableCacheEntry<string, User> entry, UserConnection arg)
        {
            var connection = (from conn in entry.Value.Connections
                             where conn.ConnectionId == arg.ConnectionId
                             select conn).FirstOrDefault();
            if(connection == null)
            {
                //this is a new connection
                entry.Value.Connections.Add(arg);
                return true;
            }

            if(arg.Disconnected)
            {
                entry.Value.Connections.Remove(connection);
            }
            else
            {
                connection.LastActivity = DateTime.Now;
            }

            return true;
        }
    }
公共类UserConnectionUpdateProcessor:ICacheEntryProcessor
{
/// 
///处理更新
/// 
/// 
/// 
/// 
公共bool进程(IMutableCacheEntry条目,UserConnection参数)
{
var connection=(从entry.Value.Connections中的conn
其中conn.ConnectionId==arg.ConnectionId
选择conn.FirstOrDefault();
if(连接==null)
{
//这是一个新的连接
entry.Value.Connections.Add(arg);
返回true;
}
如果(参数已断开)
{
entry.Value.Connections.Remove(连接);
}
其他的
{
connection.LastActivity=DateTime.Now;
}
返回true;
}
}
我启用了Ignite跟踪日志,并将其打印出来

2020-06-21 21:09:54.1732|DEBUG|org.apache.ignite.internal.processors.cache.distributed.dht.atomic.GridDhtAtomicCache|<usersCache> Entry did not pass the filter or conflict resolution (will skip write) [entry=GridDhtCacheEntry [rdrs=ReaderId[] [], part=358, super=GridDistributedCacheEntry [super=GridCacheMapEntry [key=KeyCacheObjectImpl [part=358,
2020-06-21 21:09:54.1732 | DEBUG | org.apache.ignite.internal.processors.cache.distributed.dht.atomic.GridDhtAtomicCache |项未通过筛选或冲突解决(将跳过写入)[Entry=GriddhTCachentry[rdrs=ReaderId[],part=358,super=GriddributedCacheEntry[super=GridCacheMapEntry[key=KeyObjectImpl[part=358,
我还通过Ignite source了解了执行的操作。还没有运气


您的代码很好,但由于您只更改
条目.Value
对象中的数据,因此Ignite不会检测到这些更改,也不会更新条目

在返回真值之前添加
entry.Value=entry.Value

Ignite使用
属性设置器将条目标记为已更新。

您能在github或其他地方粘贴一个小型复制器项目吗?嗨@alamar,我找到了这个问题的解决方案,标记为已接受的答案。感谢快速帮助Pavel Tupitsyn。这很有效!。。