using System.Runtime.Serialization; using ServiceStack.CacheAccess; using ServiceStack.Common; using ServiceStack.OrmLite; using ServiceStack.ServiceHost; using ServiceStack.ServiceInterface; using ServiceStack.WebHost.IntegrationTests.Tests; namespace ServiceStack.WebHost.IntegrationTests.Services { [DataContract] [RestService("/cached/protobuf", "GET")] [RestService("/cached/protobuf/{FromAddress}")] public class CachedProtoBufEmail { [DataMember(Order = 1)] public string FromAddress { get; set; } } [DataContract] [RestService("/uncached/protobuf", "GET")] [RestService("/uncached/protobuf/{FromAddress}")] public class UncachedProtoBufEmail { [DataMember(Order = 1)] public string FromAddress { get; set; } } class UncachedProtoBufEmailService : RestServiceBase { public IDbConnectionFactory DbFactory { get; set; } public ICacheClient CacheClient { get; set; } public override object OnGet(UncachedProtoBufEmail request) { return new ProtoBufEmail() {FromAddress = request.FromAddress}; } } class CachedProtoBufEmailService : RestServiceBase { public IDbConnectionFactory DbFactory { get; set; } public ICacheClient CacheClient { get; set; } public override object OnGet(CachedProtoBufEmail request) { return base.RequestContext.ToOptimizedResultUsingCache( this.CacheClient, UrnId.Create(request.FromAddress ?? "none"), () => new ProtoBufEmail() { FromAddress = request.FromAddress }); } } }