From 351cfef7a70ef311801be0bc9eb9e3891265d22b Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Mon, 3 Feb 2014 23:04:19 -0500 Subject: use conditional caching on some json responses --- MediaBrowser.Controller/Entities/BaseItem.cs | 9 +++++++++ MediaBrowser.Controller/Entities/CollectionFolder.cs | 4 ++-- MediaBrowser.Controller/Entities/Folder.cs | 2 +- MediaBrowser.Controller/Net/IHttpResultFactory.cs | 14 ++++++++++++-- 4 files changed, 24 insertions(+), 5 deletions(-) (limited to 'MediaBrowser.Controller') diff --git a/MediaBrowser.Controller/Entities/BaseItem.cs b/MediaBrowser.Controller/Entities/BaseItem.cs index 5a041860bb..650a9bad09 100644 --- a/MediaBrowser.Controller/Entities/BaseItem.cs +++ b/MediaBrowser.Controller/Entities/BaseItem.cs @@ -253,6 +253,15 @@ namespace MediaBrowser.Controller.Entities } } + [IgnoreDataMember] + public IEnumerable PhysicalLocations + { + get + { + return ResolveArgs.PhysicalLocations; + } + } + /// /// Resets the resolve args. /// diff --git a/MediaBrowser.Controller/Entities/CollectionFolder.cs b/MediaBrowser.Controller/Entities/CollectionFolder.cs index 0d6bed90b9..6220bc4d51 100644 --- a/MediaBrowser.Controller/Entities/CollectionFolder.cs +++ b/MediaBrowser.Controller/Entities/CollectionFolder.cs @@ -84,7 +84,7 @@ namespace MediaBrowser.Controller.Entities try { - locationsDicionary = ResolveArgs.PhysicalLocations.ToDictionary(i => i, StringComparer.OrdinalIgnoreCase); + locationsDicionary = PhysicalLocations.ToDictionary(i => i, StringComparer.OrdinalIgnoreCase); } catch (IOException ex) { @@ -116,7 +116,7 @@ namespace MediaBrowser.Controller.Entities try { - locationsDicionary = ResolveArgs.PhysicalLocations.ToDictionary(i => i, StringComparer.OrdinalIgnoreCase); + locationsDicionary = PhysicalLocations.ToDictionary(i => i, StringComparer.OrdinalIgnoreCase); } catch (IOException ex) { diff --git a/MediaBrowser.Controller/Entities/Folder.cs b/MediaBrowser.Controller/Entities/Folder.cs index 94db048647..02da2fe618 100644 --- a/MediaBrowser.Controller/Entities/Folder.cs +++ b/MediaBrowser.Controller/Entities/Folder.cs @@ -1079,7 +1079,7 @@ namespace MediaBrowser.Controller.Entities if (i.LocationType != LocationType.Remote) { - if (i.ResolveArgs.PhysicalLocations.Contains(path, StringComparer.OrdinalIgnoreCase)) + if (i.PhysicalLocations.Contains(path, StringComparer.OrdinalIgnoreCase)) { return true; } diff --git a/MediaBrowser.Controller/Net/IHttpResultFactory.cs b/MediaBrowser.Controller/Net/IHttpResultFactory.cs index 0614db12e6..b7dff96cd9 100644 --- a/MediaBrowser.Controller/Net/IHttpResultFactory.cs +++ b/MediaBrowser.Controller/Net/IHttpResultFactory.cs @@ -50,7 +50,7 @@ namespace MediaBrowser.Controller.Net /// The factory function that creates the response object. /// The response headers. /// System.Object. - object GetOptimizedResultUsingCache(IRequest requestContext, Guid cacheKey, DateTime lastDateModified, TimeSpan? cacheDuration, Func factoryFn, IDictionary responseHeaders = null) + object GetOptimizedResultUsingCache(IRequest requestContext, Guid cacheKey, DateTime? lastDateModified, TimeSpan? cacheDuration, Func factoryFn, IDictionary responseHeaders = null) where T : class; /// @@ -65,7 +65,7 @@ namespace MediaBrowser.Controller.Net /// Type of the content. /// The response headers. /// System.Object. - object GetCachedResult(IRequest requestContext, Guid cacheKey, DateTime lastDateModified, TimeSpan? cacheDuration, Func factoryFn, string contentType, IDictionary responseHeaders = null) + object GetCachedResult(IRequest requestContext, Guid cacheKey, DateTime? lastDateModified, TimeSpan? cacheDuration, Func factoryFn, string contentType, IDictionary responseHeaders = null) where T : class; /// @@ -94,5 +94,15 @@ namespace MediaBrowser.Controller.Net /// if set to true [is head request]. /// System.Object. object GetStaticFileResult(IRequest requestContext, string path, FileShare fileShare = FileShare.Read, IDictionary responseHeaders = null, bool isHeadRequest = false); + + /// + /// Gets the optimized serialized result using cache. + /// + /// + /// The request. + /// The result. + /// System.Object. + object GetOptimizedSerializedResultUsingCache(IRequest request, T result) + where T : class; } } -- cgit v1.2.3