Giter VIP home page Giter VIP logo

aspnetwebapi-outputcache-mongodb's Introduction

ASP.NET Web API CacheOutput - MongoDb

MongoDb 'provider' for AspNetWebApi-OutputCache
Implementation of IApiOutputCache for MongoDb

Usage

Simply create an instance of MongoDbApiOutputCache

MongoDbApiOutputCache takes a MongoDatabase in the ctor, so you can pass this in via IoC.
You can also specify your cache collection name. Default is "cache".

From the AspNetWebApi-OutputCache readme:

You can register your implementation using a handy GlobalConfiguration extension method:

//instance
configuration.CacheOutputConfiguration().RegisterCacheOutputProvider(() => new MyCache());

//singleton
var cache = new MyCache();
configuration.CacheOutputConfiguration().RegisterCacheOutputProvider(() => cache);	

If you prefer CacheOutput to use resolve the cache implementation directly from your dependency injection provider, that's also possible. Simply register your IApiOutputCache implementation in your Web API DI and that's it. Whenever CacheOutput does not find an implementation in the GlobalConiguration, it will fall back to the DI resolver. Example (using Autofac for Web API):

cache = new MyCache();
var builder = new ContainerBuilder();
builder.RegisterInstance(cache);
config.DependencyResolver = new AutofacWebApiDependencyResolver(builder.Build());

aspnetwebapi-outputcache-mongodb's People

Contributors

alexjamesbrown avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

aspnetwebapi-outputcache-mongodb's Issues

Getting error

I have added your library in my web api project. In the Application_Start() I'm instantiating the cacheoutput configuration as below -

var client = new MongoClient(ConfigurationManager.ConnectionStrings["MongoDB"].ConnectionString);
var db = client.GetServer().GetDatabase("dbname");
GlobalConfiguration.Configuration.CacheOutputConfiguration().RegisterCacheOutputProvider(() => new MongoDbApiOutputCache(db));

But when trying to access an action that has 'CacheOutput' attribute giving me below error --

Method 'get_AllKeys' in type 'WebAPI.OutputCache.MongoDb.MongoDbApiOutputCache' from assembly 'WebAPI.OutputCache.MongoDb, Version=1.0.5235.20534, Culture=neutral, PublicKeyToken=null' does not have an implementation.

Really appreciate if you please let me know if I'm missing anything. Thanks in advance.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.