This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static string Serialize(object o, StringEscapeHandling stringEscapeHandling) | |
{ | |
StringWriter wr = new StringWriter(); | |
var jsonWriter = new JsonTextWriter(wr); | |
jsonWriter.StringEscapeHandling = stringEscapeHandling; | |
new JsonSerializer().Serialize(jsonWriter, o); | |
return wr.ToString(); | |
} | |
//usage |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<div class="info"> | |
<h1>#dogoparty, #dogostore, #dogohq</h1> | |
<p>Profilini "HERKESE AÇIK" duruma getirmeyi unutma!</p> | |
<a class="" href="/"> | |
<div class="Igw0E rBNOH eGOV_ ybXk5 _4EzTm"> | |
<span class="glyphsSpriteApp_instagram__outline__24__grey_9 u-__7" aria-label="Instagram"></span> | |
<div class="SvO5t"></div> | |
<div class="cq2ai"> | |
<span class="glyphsSpriteMobile_nav_type_logo u-__7" aria-label="Instagram"></span> | |
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using StackExchange.Redis; | |
namespace RedisNetApi.Handlers | |
{ | |
public static class ConnectionHandler | |
{ | |
public static IDatabase GetRedisDatabase(string connectionString = "redis_image") | |
{ | |
if (string.IsNullOrEmpty(connectionString)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using StackExchange.Redis; | |
namespace RedisNetApi.Caching | |
{ | |
public interface IRedisProvider | |
{ | |
T Get<T>(IDatabase cache, string key); | |
void Set(IDatabase cache, string key, object value, TimeSpan experation); | |
bool DeleteCacheKeyContains(IDatabase database, string keyPattern, string connectionString = "127.0.0.1"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Diagnostics; | |
using Newtonsoft.Json; | |
using StackExchange.Redis; | |
namespace RedisNetApi.Caching | |
{ | |
public class RedisProvider : IRedisProvider | |
{ | |
//string tipinde alınan veriyi deserialize ederek T tipinde bir objeye çevirir. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Threading.Tasks; | |
namespace RedisNetApi.Caching | |
{ | |
public interface IResponseCacheFactory | |
{ | |
Task CacheResponseAsync(string cacheKey, object response, TimeSpan expireTimeSeconds); | |
Task<string> GetCachedResponseAsync(string cacheKey); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Threading.Tasks; | |
using Microsoft.Extensions.Caching.Distributed; | |
using Newtonsoft.Json; | |
namespace RedisNetApi.Caching | |
{ | |
public class ResponseCacheFactory : IResponseCacheFactory | |
{ | |
private readonly IDistributedCache _distrubtedCache; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Linq; | |
using System.Text; | |
using System.Threading.Tasks; | |
using Microsoft.AspNetCore.Http; | |
using Microsoft.AspNetCore.Mvc; | |
using Microsoft.AspNetCore.Mvc.Filters; | |
using Microsoft.Extensions.DependencyInjection; | |
using RedisNetApi.Caching; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Collections.Concurrent; | |
public class Program | |
{ | |
public static void Main() | |
{ | |
ConcurrentDictionary<string,int> dictionary = new ConcurrentDictionary<string,int>(); | |
dictionary.TryAdd("Mehmet",25); | |
dictionary.TryAdd("İlker",22); | |
dictionary.TryAdd("Beril",30); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Collections.Generic; | |
public class Program | |
{ | |
public static void Main() | |
{ | |
Dictionary<string,int> dictionary = new Dictionary<string,int> { {"Mehmet",25}, {"İlker",22}, {"Beril",30}, {"Bihter",28},{"Kutay",28},{"Tuğçe",26}}; | |
foreach(var item in dictionary) | |
{ |
OlderNewer