dmuka3.CS.Simple.RamDb
1.0.2
There is a newer version of this package available.
See the version list below for details.
See the version list below for details.
dotnet add package dmuka3.CS.Simple.RamDb --version 1.0.2
NuGet\Install-Package dmuka3.CS.Simple.RamDb -Version 1.0.2
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="dmuka3.CS.Simple.RamDb" Version="1.0.2" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add dmuka3.CS.Simple.RamDb --version 1.0.2
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: dmuka3.CS.Simple.RamDb, 1.0.2"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install dmuka3.CS.Simple.RamDb as a Cake Addin #addin nuget:?package=dmuka3.CS.Simple.RamDb&version=1.0.2 // Install dmuka3.CS.Simple.RamDb as a Cake Tool #tool nuget:?package=dmuka3.CS.Simple.RamDb&version=1.0.2
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
dmuka3.CS.Simple.RamDb
This library provides you to store data on RAM. It will never save to disk just like Redis.
Nuget
Link : https://www.nuget.org/packages/dmuka3.CS.Simple.RamDb
Install-Package dmuka3.CS.Simple.RamDb
Example 1
We should create a server to connect and to get datas from it. After that, we will connect to this server.
// Creating a server.
RamDbServer server = new RamDbServer("muhammed", "123123", 2048, 4, 9090, timeOutAuth: 1);
// We have to start it on background.
new Thread(() =>
{
server.Start();
}).Start();
// Wait for server.
Thread.Sleep(1000);
// Client to connect to the server.
RamDbClient client = new RamDbClient("127.0.0.1", 9090);
// Connected.
client.Start("muhammed", "123123", 2048);
// Create a key with value for 30 second.
client.SetValue("TEST_KEY", "MUHAMMET KANDEMİR", TimeSpan.FromSeconds(30), out _);
// Get a value by key.
var v = client.GetValue("TEST_KEY");
// Close client.
client.Dispose();
// Close server.
server.Dispose();
Assert.AreEqual(v, "MUHAMMET KANDEMİR");
You may wonder what is the "2048". It is key size of RSA. We always use RSA during communication on TCP. This is security to save your secret datas.
Also, we will show you how to lock a data on single thread.
Example 2
// Create a server.
RamDbServer server = new RamDbServer("muhammed", "123123", 2048, 4, 9090, timeOutAuth: 1);
// Run the server on background.
new Thread(() =>
{
server.Start();
}).Start();
// Wait server.
Thread.Sleep(1000);
// Create client.
RamDbClient client = new RamDbClient("127.0.0.1", 9090);
// Connect to the server.
client.Start("muhammed", "123123", 2048);
// Our test variables.
List<bool> l = new List<bool>();
List<Thread> ts = new List<Thread>();
bool err = false;
for (int i = 0; i < 10; i++)
{
ts.Add(new Thread(() =>
{
try
{
for (int j = 0; j < 5; j++)
{
// Here is fairly important.
// Because we are checking the queue on a single thread.
// When we come here with double thread, first thread will pass but second will stop here and wait previous thread to unlock the queue.
client.Lock("TEST_LOCK_KEY", TimeSpan.FromSeconds(30));
l.Add(true);
foreach (var item in l)
Thread.Sleep(1);
// We unlock the queue for next thread.
client.UnLock("TEST_LOCK_KEY");
}
}
catch (Exception ex)
{
err = true;
}
}));
}
foreach (var item in ts)
item.Start();
Thread.Sleep(5000);
client.Dispose();
server.Dispose();
Assert.IsFalse(err);
Assert.AreEqual(l.Count, 50);
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. |
.NET Core | netcoreapp3.0 is compatible. netcoreapp3.1 was computed. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
-
.NETCoreApp 3.0
- dmuka3.CS.Simple.RSA (>= 1.0.1)
- dmuka3.CS.Simple.Semaphore (>= 1.0.1)
- dmuka3.CS.Simple.TCP (>= 1.0.2)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.