受欢迎的博客标签

Redis有四种序列化方式

Published

Serialization To offer the opportunity to store a class into Redis, that class must be serializable;

right now there are three serialization options:

BinarySerialization (Requires SerializableAttribute on top of the class to store into Redis)

NewtonSoft (Uses JSon.Net to serialize a class without SerializableAttribute)

Jil (Use super fast json serializer)

MessagePack CLI (serialization/deserialization for CLI)  .

System.Net.Http.Json

 

use Newtonsoft.Json

using System.Net.Http;
using Newtonsoft.Json;

using Stockso.BlazorServer.Helpers;
using Stockso.Models.Search;


namespace Stockso.BlazorServer.Services.WebApiV1
{
    public class StockDataPhysicalDiskWebApiV1Service
    {
        public async Task<StockPanKouSearchModel> GetPanKouAggregateAuctionSearchMenuAsyncAsync()
        {
            HttpClient http = new HttpClient();
            var json = await http.GetStringAsync($"{GlobalHelper.BaseUrl}/api/v1/StockDataPhysicalDiskPanKouAggregateAuctionSearch/MenuAsync");

            var i = JsonConvert.DeserializeObject<StockPanKouSearchModel>(json);

            return JsonConvert.DeserializeObject<StockPanKouSearchModel>(json);


        }
    }
}

using System.Net.Http.Json

@code {
    ProductStock[] developers { get; set; }
    protected override async Task OnInitializedAsync()
    {
        developers = await client.GetFromJsonAsync<ProductStock[]>("http://localhost:5000/api/ProductStock");
    }
}