标签:div eric webapi empty src alt 参数 api 安装
using System; using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; using Microsoft.AspNetCore.Mvc; using Microsoft.Extensions.Logging; // For more information on enabling Web API for empty projects, visit https://go.microsoft.com/fwlink/?LinkID=397860 namespace DemoCore.Controllers { [Route("api/[controller]/[action]")] //Api控制器 [ApiController] public class HomeController : Controller { private ILogger _logger; public HomeController(ILogger<HomeController> logger) { _logger = logger; } // GET: api/<controller> [HttpGet] public IEnumerable<string> Get() { var csredis = new CSRedis.CSRedisClient(null, "127.0.0.1:6379,defaultDatabase=11,poolsize=10,ssl=false,writeBuffer=10240,prefix=btkey_", "120.79.21.96:6379,defaultDatabase=14,poolsize=13,ssl=false,writeBuffer=10240,prefix=key_"); //实现思路:根据key.GetHashCode() % 节点总数量,确定连向的节点 //也可以自定义规则(第一个参数设置) //初始化 RedisHelper RedisHelper.Initialization(csredis); RedisHelper.Set("name1", "祝雷1");//设置值。默认永不过期 RedisHelper.Set("name2", "祝雷2");//设置值。默认永不过期 RedisHelper.Set("name1", "祝雷11");//设置值。默认永不过期 RedisHelper.Set("name2", "祝雷22");//设置值。默认永不过期 RedisHelper.Set("name", "祝雷");//设置值。默认永不过期 string str=RedisHelper.Get("name");//取值 _logger.LogInformation("测试一下,不要紧张!"); return new string[] { "value1", "value2" }; } } }
三、Signalr WebApi客服-客户链接+Redis(集群扩展)
标签:div eric webapi empty src alt 参数 api 安装
原文地址:https://www.cnblogs.com/fger/p/12119396.html