Skip to content
Merged
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
Binary file added lib/AWSSDK.dll
Binary file not shown.
448 changes: 448 additions & 0 deletions src/ServiceStack.CacheAccess.AwsDynamoDb/DynamoDbCacheClient.cs

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;

// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("ServiceStack.CacheAccess.AwsDynamoDb")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("ServiceStack.CacheAccess.AwsDynamoDb")]
[assembly: AssemblyCopyright("Copyright © 2012")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]

// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]

// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("95e6e10a-af25-42bb-8dbc-c1d817e2aaa6")]

// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{29C23E7D-F41E-42DD-8426-9B5254840450}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>ServiceStack.CacheAccess.AwsDynamoDb</RootNamespace>
<AssemblyName>ServiceStack.CacheAccess.AwsDynamoDb</AssemblyName>
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="AWSSDK, Version=1.5.6.0, Culture=neutral, PublicKeyToken=cd2d24cd2bace800, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\lib\AWSSDK.dll</HintPath>
</Reference>
<Reference Include="ServiceStack.Interfaces">
<HintPath>..\..\lib\ServiceStack.Interfaces.dll</HintPath>
</Reference>
<Reference Include="ServiceStack.Text">
<HintPath>..\..\lib\ServiceStack.Text.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="DynamoDbCacheClient.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>
25 changes: 23 additions & 2 deletions src/ServiceStack.Contrib.sln
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Microsoft Visual Studio Solution File, Format Version 11.00
# Visual Studio 2010
Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 2012
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "tests", "tests", "{1CA66D0F-9000-4AB6-A71A-4E64F1A391B8}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ServiceStack.Compression", "ServiceStack.Compression\ServiceStack.Compression.csproj", "{EC12FEF4-E335-4C9D-9AA0-764A2203C26F}"
Expand All @@ -24,6 +24,10 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ServiceStack.CacheAccess.Me
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ServiceStack.CacheAccess.Azure", "ServiceStack.CacheAccess.Azure\ServiceStack.CacheAccess.Azure.csproj", "{08840867-041E-46A2-97C3-EA223161D942}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ServiceStack.CacheAccess.AwsDynamoDb", "ServiceStack.CacheAccess.AwsDynamoDb\ServiceStack.CacheAccess.AwsDynamoDb.csproj", "{29C23E7D-F41E-42DD-8426-9B5254840450}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ServiceStack.CacheAccess.AwsDynamoDb.Tests", "..\tests\ServiceStack.CacheAccess.AwsDynamoDb.Tests\ServiceStack.CacheAccess.AwsDynamoDb.Tests.csproj", "{27217138-EA6A-466F-83D4-A4585C921781}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -80,11 +84,28 @@ Global
{08840867-041E-46A2-97C3-EA223161D942}.Release|Any CPU.Build.0 = Release|Any CPU
{08840867-041E-46A2-97C3-EA223161D942}.STATIC_ONLY NO_EXPRESSIONS|Any CPU.ActiveCfg = Release|Any CPU
{08840867-041E-46A2-97C3-EA223161D942}.STATIC_ONLY NO_EXPRESSIONS|Any CPU.Build.0 = Release|Any CPU
{29C23E7D-F41E-42DD-8426-9B5254840450}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{29C23E7D-F41E-42DD-8426-9B5254840450}.Debug|Any CPU.Build.0 = Debug|Any CPU
{29C23E7D-F41E-42DD-8426-9B5254840450}.MonoTouch|Any CPU.ActiveCfg = Release|Any CPU
{29C23E7D-F41E-42DD-8426-9B5254840450}.MonoTouch|Any CPU.Build.0 = Release|Any CPU
{29C23E7D-F41E-42DD-8426-9B5254840450}.Release|Any CPU.ActiveCfg = Release|Any CPU
{29C23E7D-F41E-42DD-8426-9B5254840450}.Release|Any CPU.Build.0 = Release|Any CPU
{29C23E7D-F41E-42DD-8426-9B5254840450}.STATIC_ONLY NO_EXPRESSIONS|Any CPU.ActiveCfg = Release|Any CPU
{29C23E7D-F41E-42DD-8426-9B5254840450}.STATIC_ONLY NO_EXPRESSIONS|Any CPU.Build.0 = Release|Any CPU
{27217138-EA6A-466F-83D4-A4585C921781}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{27217138-EA6A-466F-83D4-A4585C921781}.Debug|Any CPU.Build.0 = Debug|Any CPU
{27217138-EA6A-466F-83D4-A4585C921781}.MonoTouch|Any CPU.ActiveCfg = Release|Any CPU
{27217138-EA6A-466F-83D4-A4585C921781}.MonoTouch|Any CPU.Build.0 = Release|Any CPU
{27217138-EA6A-466F-83D4-A4585C921781}.Release|Any CPU.ActiveCfg = Release|Any CPU
{27217138-EA6A-466F-83D4-A4585C921781}.Release|Any CPU.Build.0 = Release|Any CPU
{27217138-EA6A-466F-83D4-A4585C921781}.STATIC_ONLY NO_EXPRESSIONS|Any CPU.ActiveCfg = Release|Any CPU
{27217138-EA6A-466F-83D4-A4585C921781}.STATIC_ONLY NO_EXPRESSIONS|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(NestedProjects) = preSolution
{3EEF88B9-14A0-466D-B364-24D5D0E9BE75} = {1CA66D0F-9000-4AB6-A71A-4E64F1A391B8}
{27217138-EA6A-466F-83D4-A4585C921781} = {1CA66D0F-9000-4AB6-A71A-4E64F1A391B8}
EndGlobalSection
EndGlobal
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Amazon;
using NUnit.Framework;

namespace ServiceStack.CacheAccess.AwsDynamoDb.Tests
{
[TestFixture]
public class DynamoDbCacheClientTests
{
// Replace these with your prod/test AWS account to run unit tests.
private const string yourAwsAccountKey = "SOME.KEY";
private const string yourAwsSecretKey = "SOME.SECRET.KEY";

public class DummyObject
{
public string UserId { get; set; }
public string Email { get; set; }
public string Phone { get; set; }
public List<string> Friends { get; set; }
}

private ICacheClient _client;
private DummyObject _item;
private string _itemCacheKey = "urn:dummyobject:john.doe";
private string _counterCacheKey = "urn:counter";

[SetUp]
public void SetupTests()
{

_client = new DynamoDbCacheClient(yourAwsAccountKey, yourAwsSecretKey,
RegionEndpoint.USEast1, "ICacheClientDynamoDb", 10, 5, true);
// The primary item we'll be caching in the tests.
_item = new DummyObject
{
UserId = "john.doe",
Email = "john.doe@servicestack.net",
Phone = "555-555-9876",
Friends = new List<string> {"jane.doe", "jack.doe", "some.friend"}
};
}

[Test]
public void DyanmoDb_ExerciseCacheClient()
{
// Expecting the Set operation to succeed
bool setResponse = _client.Set<DummyObject>(_itemCacheKey, _item);
Assert.AreEqual(true, setResponse);

// Expecting the Get to return the item cached above
var actual = _client.Get<DummyObject>(_itemCacheKey);
Assert.IsNotNull(actual);
Assert.AreEqual(_item.UserId, actual.UserId);

// Expecting Add to return false since the item is already cached
bool addResponse = _client.Add<DummyObject>(_itemCacheKey, _item);
Assert.AreEqual(false, addResponse);

// Expecting remove to succeed
bool removeResponse = _client.Remove(_itemCacheKey);
Assert.AreEqual(true, removeResponse);

// Add the item back, expecting success
addResponse = _client.Add<DummyObject>(_itemCacheKey, _item);
Assert.AreEqual(true, addResponse);

// Remove it again
removeResponse = _client.Remove(_itemCacheKey);

// Clear the counter if it exists
removeResponse = _client.Remove(_counterCacheKey);

// Initialize the counter, incResponse should be equal to 0 since the counter doesn't exist
long incResponse = _client.Increment(_counterCacheKey, 0);

// Increment by 1
long updatedIncResponse = _client.Increment(_counterCacheKey, 1);
Assert.AreEqual(incResponse + 1, updatedIncResponse);
// Decrement by 1
long decResponse = _client.Decrement(_counterCacheKey, 1);
Assert.AreEqual(incResponse, decResponse);

// Clear out the cache - this will cause a very long delete/re-create DynamoDB table sequence
_client.FlushAll();

}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;

// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("ServiceStack.CacheAccess.AwsDynamoDb.Tests")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("ServiceStack.CacheAccess.AwsDynamoDb.Tests")]
[assembly: AssemblyCopyright("Copyright © 2012")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]

// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]

// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("96e25089-a6d1-45ba-944f-8c6461601b88")]

// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{27217138-EA6A-466F-83D4-A4585C921781}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>ServiceStack.CacheAccess.AwsDynamoDb.Tests</RootNamespace>
<AssemblyName>ServiceStack.CacheAccess.AwsDynamoDb.Tests</AssemblyName>
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="AWSSDK, Version=1.5.6.0, Culture=neutral, PublicKeyToken=cd2d24cd2bace800, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\lib\AWSSDK.dll</HintPath>
</Reference>
<Reference Include="nunit.framework">
<HintPath>..\..\lib\tests\nunit.framework.dll</HintPath>
</Reference>
<Reference Include="ServiceStack.Interfaces">
<HintPath>..\..\lib\ServiceStack.Interfaces.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="DynamoDbCacheClientTests.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\src\ServiceStack.CacheAccess.AwsDynamoDb\ServiceStack.CacheAccess.AwsDynamoDb.csproj">
<Project>{29c23e7d-f41e-42dd-8426-9b5254840450}</Project>
<Name>ServiceStack.CacheAccess.AwsDynamoDb</Name>
</ProjectReference>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>