RethinkDB.DistributedCache
View Source Repo
This library is an IDistributedCache
implementation for use in ASP.NET Core applications that uses RethinkDB for its backing data store.
How to Get It
The package is on NuGet; install it via the command-line or the graphical interface of your favorite IDE.
How to Use It
Ensure You Have a RethinkDB Connection
The caching provider does not try to obtain its own RethinkDB connection; it must be provided to it when it is registered. RethinkDB is well supported in .NET, in both C# and F#. The remainder of the examples assume that you have a configured IConnection
object named conn
.
Quick Start in C#
using RethinkDB.DistributedCache; // within ASP.NET Core service configuration builder.Services.AddDistributedRethinkDBCache(opts => opts.Connection = conn);
Quick Start in F#
open RethinkDB.DistributedCache // within ASP.NET Core service configuration let _ = builder.Services.AddDistributedRethinkDBCache(fun opts -> opts.Connection <- conn)
Configuration Options
In addition to Connection
, there are four other options you can configure.
Database
is the name of the database where the cache table will be stored. If it is not specified, the provider will use the connection's default database.TableName
is the table for the cache; if it is not specified, the provider will use the “Cache” table. (The provider ensures that the table and its indexes exist; you do not need to create them beforehand, unless the connection is restricted from creating tables and indexes.)DeleteExpiredInterval
controls how frequently expired cache entries will be purged; it is aTimeSpan
and defaults to 30 minutes.DefaultSlidingExpiration
controls how frequently a cache entry with “sliding” expiration must be accessed to remain valid. With sliding expiration, every time a cache entry is accessed, the expiration is pushed out by this amount. It is also aTimeSpan
and defaults to 20 minutes.
How to Improve It
If you have ideas for improving this project, feel free to open up an issue and let us know!