NetBlog主题

.net Core 增删改查Redis,添加Redis数据过期时间
.Net Core

.net Core 增删改查Redis,添加Redis数据过期时间

5451

Redis: REmote DIctionary Server 远程字典(内存)服务器,基于内存管理(数据全部存在内存),实现了多种数据结构的,单线程模型的应用程序,提供插入-查询-固化-集群功能。Redis特点:速度快,数据可能丢失,只能做缓存,而不是存储。以下核心代码(这里采用的是StackExchange)…

.net Core微服务架构之健康检查和自定义负载均衡策略
.Net Core

.net Core微服务架构之健康检查和自定义负载均衡策略

3431

.net Core微服务架构之健康检查和自定义负载均衡策略 以下是框架结构图Nuget下载Consul,服务注册核心代码(写了一个扩展方法) Nuget下载Consul,服务注册核心代码(写了一个扩展方法) public static class ConsuHelper {public static void ConsuRegist(this IConfiguration c…

.net Core添加命令行读取功能
.Net Core

.net Core添加命令行读取功能

2793

集群是:多台服务器提供相同功能,增强处理能力和容错能力。所有多台服务器的程序都一样,但各台服务器IP不一样,端口也可能不一样,我们要把服务器IP和端口告诉Consul,在这里有两种方法 方法一(从命令行读取IP和端口)在程序入口 Main方法里面添加命令行读取功能代码如下publ…

.net Core,Lucene.net,Jieba.net站内搜索
.Net Core

.net Core,Lucene.net,Jieba.net站内搜索

3207

2021-12-05 更新核心代码/// summary/// Jieba.net分词/// /summary/// param name="key"/param/// returns/returnspublic Liststring CutKeyWord(string key){var rs = new Liststring();var segmenter = new JiebaSegmenter();var list = segmenter…

.net core实现WebSocket通讯
.Net Core

.net core实现WebSocket通讯

7363

以下是Startup类下的核心代码 这里用的是.net core 2.0 如果更高版本 也差不多稍微改动一点就可以 public void ConfigureServices(IServiceCollection services) {services.AddMvc(); }// This method gets called by the runtime. Use this method to configure the HTTP req…

.net core实现404错误跳转指定页
.Net Core

.net core实现404错误跳转指定页

3950

如果输入的地址不存在或者原因地址被删除等问题,我们可以用下面方法实现跳转到指定的页面,在这里我是跳转到了首页代码如下 public class Jump404Middleware {private readonly RequestDelegate next;public Jump404Middleware(RequestDelegate next){this.next = next;}publ…

.net Core添加和删除缓存
.Net Core

.net Core添加和删除缓存

4834

using Microsoft.Extensions.Caching.Memory; using System;namespace lqwvje.Common {public class CacheHelper{ //原创来自 http://www.luofenming.com/show.aspx?id=ART2019101900001public static IMemoryCache _memoryCache = new MemoryCache(new MemoryCacheOptions…

.net Core web网站发布到IIS
.Net Core

.net Core web网站发布到IIS

3634

很多跟普通网站一样的操作,在这里就不写出来 1、需要确保IIS上已经安装AspNetCoreModule模块,各个版本的下载地址https://dotnet.microsoft.com/download/dotnet-core 在这里选的是目前最新版本的 .net Core 3.0 下载地址 https://dotnet.microsoft.com/download/dotnet-cor…