Last active
April 30, 2019 16:43
-
-
Save alistairjevans/a8739adc72729ffb9570bce57dfa99d8 to your computer and use it in GitHub Desktop.
MongoDB Lock - Setting Up
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class LockModel | |
{ | |
// We only need an ID right now | |
public string Id { get; set; } | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class LockProvider | |
{ | |
private readonly IMongoCollection<LockModel> collection; | |
public LockProvider(string mongodbConnString) | |
{ | |
// Create a lock collection | |
var client = new MongoClient(mongodbConnString); | |
var database = client.GetDatabase("mydb"); | |
// Get our collection | |
collection = database.GetCollection<LockModel>("resourceLocks"); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment