outmatic / mongodbcache Goto Github PK
View Code? Open in Web Editor NEWA distributed cache implementation based on MongoDb
Home Page: https://outmatic.pl
License: MIT License
A distributed cache implementation based on MongoDb
Home Page: https://outmatic.pl
License: MIT License
sorry
Hi,
I use MongoDbCache, it replace the StackExchange.Redis library.
The problem is that we have a "Services.AddDataProtection().PersistKeysToStackExchangeRedis" but there is no equivalent for MongoDB.
Can you provides it ?
PS: here is the source code https://github.com/aspnet/DataProtection/blob/master/src/Microsoft.AspNetCore.DataProtection.StackExchangeRedis/RedisDataProtectionBuilderExtensions.cs
MongoDB exposes a built-in "time to live" or TTL collection feature. Why not use this to expire items instead of making the application server handle the expirations?
Also the notion of capped collections may prove interesting for cache storage as well so users can control the size of the cache and behind the scenes, MongoDB takes care of treating the cache like a circular buffer.
Need NetStandart support
After having updated to v2.4.1 from v2.4.0, I get the following error:
'MongoDbCacheOptions' does not contain a definition for 'MongoClientSettings'
When looking at the class decompiled by Rider, I get the following results on v2.4.1:
// Decompiled with JetBrains decompiler
// Type: MongoDbCache.MongoDbCacheOptions
// Assembly: MongoDbCache, Version=2.2.0.0, Culture=neutral, PublicKeyToken=null
// MVID: E1CE4650-1D82-4E5B-AE0C-6D1CF6CD776C
// Assembly location: /Users/max/.nuget/packages/mongodbcache/2.4.1/lib/netcoreapp2.2/MongoDbCache.dll
using Microsoft.Extensions.Options;
using System;
namespace MongoDbCache
{
public class MongoDbCacheOptions : IOptions<MongoDbCacheOptions>
{
public string ConnectionString { get; set; }
public string DatabaseName { get; set; }
public string CollectionName { get; set; }
public TimeSpan? ExpiredScanInterval { get; set; }
MongoDbCacheOptions IOptions<MongoDbCacheOptions>.Value => this;
}
}
on v.2.4.0 it's correct:
// Decompiled with JetBrains decompiler
// Type: MongoDbCache.MongoDbCacheOptions
// Assembly: MongoDbCache, Version=2.4.0.0, Culture=neutral, PublicKeyToken=null
// MVID: 4BF98E49-540C-450A-A58D-C8429CB44B55
// Assembly location: /Users/max/.nuget/packages/mongodbcache/2.4.0/lib/netcoreapp2.2/MongoDbCache.dll
using Microsoft.Extensions.Options;
using MongoDB.Driver;
using System;
namespace MongoDbCache
{
public class MongoDbCacheOptions : IOptions<MongoDbCacheOptions>
{
public string ConnectionString { get; set; }
public MongoClientSettings MongoClientSettings { get; set; }
public string DatabaseName { get; set; }
public string CollectionName { get; set; }
public TimeSpan? ExpiredScanInterval { get; set; }
MongoDbCacheOptions IOptions<MongoDbCacheOptions>.Value => this;
}
}
Note the // Assembly: MongoDbCache, Version=2.2.0.0
vs // Assembly: MongoDbCache, Version=2.4.0.0
as well as missing using
statement and MongoClientSettings
which were added by the great @RNPValinor in PR #10.
Thanks.
So it adding records but it doesn’t take into account global cache timeouts only it works when I put configuration object into set method. Global timeouts completely not working.
However main issue is that frequently it doesn’t delete old cache just it updates timestamp, and this is completely random.
Shielding "_mongoContext.GetCacheItemAsync(key, withoutValue: true)“ is good
_mongoContext.GetCacheItemAsync > GetItemQuery > query.Project(Builders.Projection.Exclude(x => x.Value))
fail: Microsoft.AspNetCore.Session.SessionMiddleware[1]
Error closing the session.
MongoDB.Bson.BsonSerializationException: No matching creator found.
在 MongoDB.Bson.Serialization.BsonClassMapSerializer1.ChooseBestCreator(Dictionary
2 values)
在 MongoDB.Bson.Serialization.BsonClassMapSerializer1.CreateInstanceUsingCreator(Dictionary
2 values)
在 MongoDB.Bson.Serialization.BsonClassMapSerializer1.DeserializeClass(BsonDeserializationContext context) 在 MongoDB.Bson.Serialization.BsonClassMapSerializer
1.Deserialize(BsonDeserializationContext context, BsonDeserializationArgs args)
^o^
Only .NET Core 2.2 is supported as a build target. It is outdated and does not get any security updated by Microsoft anymore. Is there any readon why 2.2 is used explicitly? I made a fork and it seems that i could set netstandard2.0 as the build target which would target .NET Framework and .NET both.
All tests are running green.
There are issues in the MongoDB.Driver 2.8, see:
https://jira.mongodb.org/browse/CSHARP-2595
It is related to NET Core 3.x
So, in order to be compatible, we need an update to the last driver, right ?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.