public async ValueTask <ThumbnailCache?> FindOneAsync(NestedPath filePath, int width, int height, ThumbnailResizeType resizeType, ThumbnailFormatType formatType)
        {
            await Task.Delay(1).ConfigureAwait(false);

            using (await _asyncLock.LockAsync())
            {
                var id = new ThumbnailCacheIdEntity()
                {
                    FilePath            = NestedPathEntity.Import(filePath),
                    ThumbnailWidth      = width,
                    ThumbnailHeight     = height,
                    ThumbnailResizeType = resizeType,
                    ThumbnailFormatType = formatType,
                };
                var storage = this.GetStorage();

                var liteFileInfo = storage.FindById(id);
                if (liteFileInfo is null)
                {
                    return(null);
                }

                using (var inStream = liteFileInfo.OpenRead())
                {
                    return(RocketMessage.FromStream <ThumbnailCache>(inStream));
                }
            }
        }
        public async ValueTask InsertAsync(ThumbnailCache entity)
        {
            await Task.Delay(1).ConfigureAwait(false);

            using (await _asyncLock.LockAsync())
            {
                var id = new ThumbnailCacheIdEntity()
                {
                    FilePath            = NestedPathEntity.Import(entity.FileMeta.Path),
                    ThumbnailWidth      = (int)entity.ThumbnailMeta.Width,
                    ThumbnailHeight     = (int)entity.ThumbnailMeta.Height,
                    ThumbnailResizeType = entity.ThumbnailMeta.ResizeType,
                    ThumbnailFormatType = entity.ThumbnailMeta.FormatType,
                };
                var storage = this.GetStorage();

                if (!_database.BeginTrans())
                {
                    _logger.Error("current thread already in a transaction");
                    throw new Exception();
                }

                try
                {
                    using (var outStream = storage.OpenWrite(id, "-"))
                    {
                        RocketMessage.ToStream(entity, outStream);
                    }

                    if (!_database.Commit())
                    {
                        _logger.Error("failed to commit");
                        throw new Exception();
                    }
                }
                catch (Exception e)
                {
                    _logger.Debug(e);
                    _database.Rollback();
                }
            }
        }