Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Caching.Get Failed to deserialize EasyCaching.Disk.DiskCacheValue value. #556

Open
dongzhaosheng73 opened this issue Nov 4, 2024 · 2 comments
Assignees

Comments

@dongzhaosheng73
Copy link

Description

[Description of the bug or feature]

Steps to Reproduce

cache.zip

56caa0144409fd30d21e1abd2b29778a.dat

Failed to deserialize EasyCaching.Disk.DiskCacheValue value.

at MessagePack.MessagePackSerializer.Deserialize[T](MessagePackReader& reader, MessagePackSerializerOptions options)
at MessagePack.MessagePackSerializer.Deserialize[T](ReadOnlyMemory`1 buffer, MessagePackSerializerOptions options, CancellationToken cancellationToken)
at EasyCaching.Serialization.MessagePack.DefaultMessagePackSerializer.Deserialize[T](Byte[] bytes)
at EasyCaching.Disk.DefaultDiskCachingProvider.GetDiskCacheValue(String path)
at EasyCaching.Disk.DefaultDiskCachingProvider.BaseGet[T](String cacheKey)
at EasyCaching.Core.EasyCachingAbstractProvider.Get[T](String cacheKey)

Related code

insert short code snippets here

Expected behavior: [What you expected to happen]

Actual behavior: [What actually happened]

Specifications

  • Provider : InMemory (version 0.2.0)
  • Interceptor : AspectCore (version 0.2.0)
  • Serializer : not use
  • System : CentOS 7.2
@Memoyu Memoyu self-assigned this Nov 5, 2024
@Memoyu
Copy link
Contributor

Memoyu commented Nov 9, 2024

@dongzhaosheng73
经排查发现是缓存文件读取出来后bytes均为0,导致反序列失败。
能否提供更多的信息:

  1. 是否有能复现写入这样的数据的方式?
  2. set 调用了哪个方法?

@dongzhaosheng73
Copy link
Author

@dongzhaosheng73 经排查发现是缓存文件读取出来后bytes均为0,导致反序列失败。 能否提供更多的信息:

  1. 是否有能复现写入这样的数据的方式?
  2. set 调用了哪个方法?

1、我自己没有复现过 是通过收集用户的cache文件进行复现的 ,复现文件就是我附加带的这个 目前挺多用户反馈这个问题的
2、set方法我使用的TrySet

我的业务代码大概是
if (!CacheService.Caching.Exists(key))
{
CacheService.Caching.TrySet(key, data, CacheTime);
}
else
{
if (refreshcache)
{
CacheService.Caching.Remove(key);
CacheService.Caching.TrySet(key, data, CacheTime);
}
}

目前我处理方式是通过拦截MessagePackSerializationException ex
Remove 损坏的缓存文件

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants