Skip to content

Instantly share code, notes, and snippets.

View devdays's full-sized avatar

Bruce D Kyle devdays

View GitHub Profile
@devdays
devdays / RedisSessionState.xml
Created February 5, 2015 19:02
Redis SessionState provider in XML
<sessionState mode="Custom" customProvider="MySessionStateStore">
<providers>
<add name="MySessionStateStore"
host = "127.0.0.1" [String]
port = "" [number]
accessKey = "" [String]
ssl = "false" [true|false]
throwOnError = "true" [true|false]
retryTimeoutInMilliseconds = "0" [number]
databaseId = "0" [number]
@devdays
devdays / redis-setTimeout.cs
Created February 5, 2015 19:00
Redis Set cache timeout
cache.StringSet("key1", "value1", TimeSpan.FromMinutes(90));
@devdays
devdays / redis-setAndGetValue.cs
Created February 5, 2015 18:59
Redis Cache from .NET
IDatabase cache = Connection.GetDatabase();
// Perform cache operations using the cache object...
// Simple put of integral data types into the cache
cache.StringSet("key1", "value");
cache.StringSet("key2", 25);
// Simple get of data types from the cache
string key1 = cache.StringGet("key1");
int key2 = (int)cache.StringGet("key2");
@devdays
devdays / redis-connectionmultiplexer.cs
Created February 5, 2015 18:58
Redis connection multiplexer
ConnectionMultiplexer connection = ConnectionMultiplexer.Connect("contoso5.redis.cache.windows.net,ssl=true,password=...");
@devdays
devdays / using-redis.cs
Created February 5, 2015 18:57
redis using statement
using StackExchange.Redis;
@devdays
devdays / registeringTheLoggerAndCounter.cs
Last active August 29, 2015 14:13
Registering the instances in the container
private static void InitializeContainer(Container container)
{
// Register ConsoleLogger as a singleton
container.RegisterSingle<ILogger, ConsoleLogger>();
// container.Register<ILogger, ConsoleLogger>(Lifestyle.Singleton);
container.Register<ICounter, Counter>();
}
@devdays
devdays / ConsoleLogger.cs
Created January 19, 2015 20:11
Sample Logger for SimpleInjectorDemo
using Interfaces;
using System;
namespace Common
{
public class ConsoleLogger : ILogger
{
public void LogMessage(string message)
{
Console.WriteLine(message);
@devdays
devdays / SimpleInjectorWebApiInitializer.cs
Last active August 29, 2015 14:13
Simple Injector container initialization
using System.Web.Http;
using SimpleInjector;
using SimpleInjector.Integration.WebApi;
using Interfaces;
using Common;
public static class SimpleInjectorWebApiInitializer
{
// Make container available to the rest of the application
// Use Container to instantiate the objects you want
@devdays
devdays / pattern-MethodInjection.cs
Created January 17, 2015 21:36
Example of method injection
using System;
public interface IService
{
void Serve();
}
public class Service : IService
{
public void Serve()
@devdays
devdays / pattern-PropertyInjection.cs
Created January 17, 2015 21:30
Example of property injection
using System;
public interface IService
{
void Serve();
}
public class Service : IService
{
public void Serve()