Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion CosmosNotifyExtensibleDependency/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,7 @@ internal class NCacheChangeFeedObserver : IChangeFeedObserver
Once the project is built and assemblies created, deploy the assemblies to a cache using the method shown in the previous section. After this is done, you can start the cache.
Once the cache is started, we can test that the dependency is working. Below is a code snippet showing how an instance of the ICustomDependencyProvider implementation we have created and deployed can be used at the client side:
```csharp
string providerNName = "CosmosDbNotificationDependency"; //This is the name of your provider deployed on cache server
string providerName = "CosmosDbNotificationDependency"; //This is the name of your provider deployed on cache server

IDictionary<string, string> parameters = new Dictionary<string, string>();
parameters.Add("Key", "Customer:CustomerID:ALFKI");
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<appSettings>
<add key="CacheId" value="demoCache"/>
</appSettings>
</configuration>
Original file line number Diff line number Diff line change
@@ -0,0 +1,133 @@
using BasicUsageStackExchangeRedis;
using System;
using System.Collections.Generic;
using System.Text;

namespace NCache.StackExchange.Redis.Sample.BasicCacheOperations
{
class KeyDeleteTests
{

//------------------------------------------------Sync Methods------------------------------------------------\\

public static void DeleteExistingKey()
{
try
{
Logger.PrintTestStartInformation("Deleting already existing key from cache");

var key = Guid.NewGuid().ToString();
Program.db.StringSet(key, Program.myObjectForCaching);
var result = Program.db.KeyDelete(key);

if (result)
{
Logger.PrintSuccessfulOutcome("Item successfully deleted from cache");
}
else
{
Logger.PrintFailureOutcome("Unable to delete item from cache");
}
}
catch (Exception e)
{
Logger.PrintDataCacheException(e);
}
finally
{
Logger.PrintBreakLine();
}
}

public static void DeleteNonExistingKey()
{
try
{
Logger.PrintTestStartInformation("Deleting non-existing key from cache");

var key = Guid.NewGuid().ToString();
var result = Program.db.KeyDelete(key);

if (result)
{
Logger.PrintFailureOutcome("Item successfully deleted from cache");
}
else
{
Logger.PrintSuccessfulOutcome("Unable to delete item from cache");
}
}
catch (Exception e)
{
Logger.PrintDataCacheException(e);
}
finally
{
Logger.PrintBreakLine();
}
}

//------------------------------------------------Async Methods------------------------------------------------\\

public static void DeleteExistingKeyAsync()
{
try
{
Logger.PrintTestStartInformation("Asynchronously deleting already existing key from cache");

var key = Guid.NewGuid().ToString();
Program.db.StringSet(key, Program.myObjectForCaching);
var result = Program.db.KeyDeleteAsync(key);

result.Wait();

if (result.Result)
{
Logger.PrintSuccessfulOutcome("Item successfully deleted from cache");
}
else
{
Logger.PrintFailureOutcome("Unable to delete item from cache");
}
}
catch (Exception e)
{
Logger.PrintDataCacheException(e);
}
finally
{
Logger.PrintBreakLine();
}
}

public static void DeleteNonExistingKeyAsync()
{
try
{
Logger.PrintTestStartInformation("Asynchronously deleting non-existing key from cache");

var key = Guid.NewGuid().ToString();
var result = Program.db.KeyDeleteAsync(key);

result.Wait();

if (result.Result)
{
Logger.PrintFailureOutcome("Item successfully deleted from cache");
}
else
{
Logger.PrintSuccessfulOutcome("Unable to delete item from cache");
}
}
catch (Exception e)
{
Logger.PrintDataCacheException(e);
}
finally
{
Logger.PrintBreakLine();
}
}
}
}
Loading