Skip to content

Instantly share code, notes, and snippets.

View carlwoodhouse's full-sized avatar

Carl Woodhouse carlwoodhouse

View GitHub Profile
_cacheManager is an injected instance of ICacheManager
_signals is an injected instance of ISignals
_clock is an injected instance of IClock
var someStuff = _cacheManager.Get("somecachekey",
ctx => {
ctx.Monitor(_clock.When(Timespan.FromHours(1));
ctx.Monitor(_signals.When(string.Concat(ctx.Key, "_Evict")));
return _someRepository.Table.OrderBy(r => r.Name).ToList().Select(x => x.Name);
public interface ICategoryService : IDependency {
IEnumerable<IContentItemSummary> GetItemsForCategory(int categoryId);
IEnumerable<string> GetCategoryTypes();
Dictionary<int, string> GetCategoriesByTypeName(string typeName);
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text.RegularExpressions;
using System.Web;
namespace Patient.Framework.Caching {
public class DefaultCacheProvider : ICacheProvider {
string cacheStore = "FrameworkLocalStoreDefault";
public string CacheStoreKey {
using System;
using System.Linq;
using Orchard;
using Orchard.DisplayManagement.Descriptors;
using Orchard.Environment.Extensions;
[OrchardFeature("The.Name.of.a.Feature")]
namespace YourProvider.Providers {
public class YourPrivider : IShapeTableProvider {
public void Discover(ShapeTableBuilder builder) {
var events = _cacheManager.Get("a.magic.key", ctx => {
ctx.Monitor(_signals.When(TimeSpan.FromHours(1));
var myEvents = new List<evento>();
if (menus != null) {
var menuIds = menus.Select(x => x.MenuTypePartRecord.Id).ToList();
var eventRecords = _contentManager.Query<ReservationPart, ReservationPartRecord>().Where(x => x.Name == user && menuIds.Contains(x.Record.MenuTypePartRecord.Id).ToList();
foreach (var menu in menus)
{
var reserva = Record.MenuTypePartRecord.Id.Where(item => item.Date == menu.Record.Date).FirstOrDefault();
var contentAzDefinitions = this.cacheManager.Get(
string.Concat("Patient.Contenttypes.Az.Ids.For.", letter),
ctx => {
ctx.Monitor(this.clock.When(Timespan.FromDays(1)));
var titleDefinitions = this.letterRepository.Fetch(x => x.Title.StartsWith(letter)).toList();
var content = this.contentManager.GetMany(titleDefinitions.Select(x => x.ContentItemId), VersionOptions.Published);
var items = new List<AzLinkDefinition>();
foreach(var titleDefinition in titleDefinitions)
{
var contentItemIdsByLetter = this.cacheManager.Get(
string.Concat("Patient.Contenttypes.Az.Ids.For.", letter),
ctx => {
ctx.Monitor(this.clock.When(Timespan.FromDays(1)));
return this.letterRepository.Fetch(x => x.Title.StartsWith(letter)).toList();
}
var items = this.cacheManager.Get(
string.Concat("Patient.Contenttypes.Az.Items.For.", letter, ".By.", contentType),
ctx => {
private readonly ISuesService suesService;
// current
void SuesController(ISuesService ss)
{
this.suesService = ss;
}
// without di
void SuesController()
<location path="route">
<system.web>
<httpHandlers>
<add path="*" type="System.Web.Handlers.TransferRequestHandler" verb="GET,HEAD,POST,DEBUG,PUT,DELETE,PATCH,OPTIONS" />
</httpHandlers>
</system.web>
<!-- Required for IIS 7.0 -->
<system.webServer>
<modules runAllManagedModulesForAllRequests="true" />
<validation validateIntegratedModeConfiguration="false" />
using Orchard;
using Orchard.Caching;
using Orchard.Environment.Configuration;
using Orchard.Environment.Extensions;
using Orchard.Mvc.Filters;
using Orchard.OutputCache.Filters;
using Orchard.OutputCache.Services;
using Orchard.Services;
using Orchard.Themes;
using Patient.Core.Extensions;