Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
StackExchange.Redis
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
tsai
StackExchange.Redis
Commits
ae13b6d0
Commit
ae13b6d0
authored
Sep 25, 2014
by
mwikstrom
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added keyspace isolation extension
parent
651c5604
Changes
7
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
1711 additions
and
168 deletions
+1711
-168
StackExchange.Redis.csproj
StackExchange.Redis/StackExchange.Redis.csproj
+164
-159
Condition.cs
StackExchange.Redis/StackExchange/Redis/Condition.cs
+9
-9
BatchWrapper.cs
...dis/StackExchange/Redis/KeyspaceIsolation/BatchWrapper.cs
+17
-0
DatabaseExtension.cs
...tackExchange/Redis/KeyspaceIsolation/DatabaseExtension.cs
+55
-0
DatabaseWrapper.cs
.../StackExchange/Redis/KeyspaceIsolation/DatabaseWrapper.cs
+636
-0
TransactionWrapper.cs
...ackExchange/Redis/KeyspaceIsolation/TransactionWrapper.cs
+33
-0
WrapperBase.cs
...edis/StackExchange/Redis/KeyspaceIsolation/WrapperBase.cs
+797
-0
No files found.
StackExchange.Redis/StackExchange.Redis.csproj
View file @
ae13b6d0
...
@@ -67,6 +67,11 @@
...
@@ -67,6 +67,11 @@
<Compile
Include=
"StackExchange\Redis\ExtensionMethods.cs"
/>
<Compile
Include=
"StackExchange\Redis\ExtensionMethods.cs"
/>
<Compile
Include=
"StackExchange\Redis\HashEntry.cs"
/>
<Compile
Include=
"StackExchange\Redis\HashEntry.cs"
/>
<Compile
Include=
"StackExchange\Redis\InternalErrorEventArgs.cs"
/>
<Compile
Include=
"StackExchange\Redis\InternalErrorEventArgs.cs"
/>
<Compile
Include=
"StackExchange\Redis\KeyspaceIsolation\BatchWrapper.cs"
/>
<Compile
Include=
"StackExchange\Redis\KeyspaceIsolation\DatabaseExtension.cs"
/>
<Compile
Include=
"StackExchange\Redis\KeyspaceIsolation\DatabaseWrapper.cs"
/>
<Compile
Include=
"StackExchange\Redis\KeyspaceIsolation\TransactionWrapper.cs"
/>
<Compile
Include=
"StackExchange\Redis\KeyspaceIsolation\WrapperBase.cs"
/>
<Compile
Include=
"StackExchange\Redis\MigrateOptions.cs"
/>
<Compile
Include=
"StackExchange\Redis\MigrateOptions.cs"
/>
<Compile
Include=
"StackExchange\Redis\RedisChannel.cs"
/>
<Compile
Include=
"StackExchange\Redis\RedisChannel.cs"
/>
<Compile
Include=
"StackExchange\Redis\Bitwise.cs"
/>
<Compile
Include=
"StackExchange\Redis\Bitwise.cs"
/>
...
...
StackExchange.Redis/StackExchange/Redis/Condition.cs
View file @
ae13b6d0
...
@@ -144,11 +144,11 @@ internal override void WriteImpl(PhysicalConnection physical)
...
@@ -144,11 +144,11 @@ internal override void WriteImpl(PhysicalConnection physical)
internal
class
ExistsCondition
:
Condition
internal
class
ExistsCondition
:
Condition
{
{
readonly
bool
expectedResult
;
internal
readonly
bool
expectedResult
;
readonly
RedisValue
hashField
;
internal
readonly
RedisValue
hashField
;
readonly
RedisKey
key
;
internal
readonly
RedisKey
key
;
public
ExistsCondition
(
RedisKey
key
,
RedisValue
hashField
,
bool
expectedResult
)
public
ExistsCondition
(
RedisKey
key
,
RedisValue
hashField
,
bool
expectedResult
)
{
{
...
@@ -197,11 +197,11 @@ internal override bool TryValidate(RawResult result, out bool value)
...
@@ -197,11 +197,11 @@ internal override bool TryValidate(RawResult result, out bool value)
}
}
}
}
private
class
EqualsCondition
:
Condition
internal
class
EqualsCondition
:
Condition
{
{
readonly
bool
expectedEqual
;
internal
readonly
bool
expectedEqual
;
readonly
RedisValue
hashField
,
expectedValue
;
internal
readonly
RedisValue
hashField
,
expectedValue
;
readonly
RedisKey
key
;
internal
readonly
RedisKey
key
;
public
EqualsCondition
(
RedisKey
key
,
RedisValue
hashField
,
bool
expectedEqual
,
RedisValue
expectedValue
)
public
EqualsCondition
(
RedisKey
key
,
RedisValue
hashField
,
bool
expectedEqual
,
RedisValue
expectedValue
)
{
{
if
(
key
.
IsNull
)
throw
new
ArgumentException
(
"key"
);
if
(
key
.
IsNull
)
throw
new
ArgumentException
(
"key"
);
...
...
StackExchange.Redis/StackExchange/Redis/KeyspaceIsolation/BatchWrapper.cs
0 → 100644
View file @
ae13b6d0
using
System
;
namespace
StackExchange.Redis.StackExchange.Redis.KeyspaceIsolation
{
internal
sealed
class
BatchWrapper
:
WrapperBase
<
IBatch
>,
IBatch
{
public
BatchWrapper
(
IBatch
inner
,
RedisKey
prefix
)
:
base
(
inner
,
prefix
)
{
}
public
void
Execute
()
{
this
.
Inner
.
Execute
();
}
}
}
StackExchange.Redis/StackExchange/Redis/KeyspaceIsolation/DatabaseExtension.cs
0 → 100644
View file @
ae13b6d0
using
System
;
namespace
StackExchange.Redis.StackExchange.Redis.KeyspaceIsolation
{
/// <summary>
/// Provides the <see cref="WithKeyPrefix"/> extension method to <see cref="IDatabase"/>.
/// </summary>
public
static
class
DatabaseExtension
{
/// <summary>
/// Creates a new <see cref="IDatabase"/> instance that provides an isolated key space
/// of the specified underyling database instance.
/// </summary>
/// <param name="database">
/// The underlying database instance that the returned instance shall use.
/// </param>
/// <param name="keyPrefix">
/// The prefix that defines a key space isolation for the returned database instance.
/// </param>
/// <returns>
/// A new <see cref="IDatabase"/> instance that invokes the specified underlying
/// <paramref name="database"/> but prepends the specified <paramref name="keyPrefix"/>
/// to all key paramters and thus forms a logical key space isolation.
/// </returns>
/// <remarks>
/// <para>
/// The following methods are not supported in a key space isolated database and
/// will throw an <see cref="NotSupportedException"/> when invoked:
/// </para>
/// <list type="bullet">
/// <item><see cref="IDatabaseAsync.KeyRandomAsync(CommandFlags)"/></item>
/// <item><see cref="IDatabase.KeyRandom(CommandFlags)"/></item>
/// </list>
/// <para>
/// Please notice that keys passed to a script are prefixed (as normal) but care must
/// be taken when a script returns the name of a key as that will (currently) not be
/// "unprefixed".
/// </para>
/// </remarks>
public
static
IDatabase
WithKeyPrefix
(
this
IDatabase
database
,
RedisKey
keyPrefix
)
{
if
(
database
==
null
)
{
throw
new
ArgumentNullException
(
"database"
);
}
if
(
keyPrefix
.
IsNull
||
keyPrefix
.
Value
.
Length
==
0
)
{
throw
new
ArgumentException
(
"The specified prefix cannot be null or empty"
,
"keyPrefix"
);
}
return
new
DatabaseWrapper
(
database
,
keyPrefix
);
}
}
}
StackExchange.Redis/StackExchange/Redis/KeyspaceIsolation/DatabaseWrapper.cs
0 → 100644
View file @
ae13b6d0
This diff is collapsed.
Click to expand it.
StackExchange.Redis/StackExchange/Redis/KeyspaceIsolation/TransactionWrapper.cs
0 → 100644
View file @
ae13b6d0
using
System
;
using
System.Threading.Tasks
;
namespace
StackExchange.Redis.StackExchange.Redis.KeyspaceIsolation
{
internal
sealed
class
TransactionWrapper
:
WrapperBase
<
ITransaction
>,
ITransaction
{
public
TransactionWrapper
(
ITransaction
inner
,
RedisKey
prefix
)
:
base
(
inner
,
prefix
)
{
}
public
ConditionResult
AddCondition
(
Condition
condition
)
{
return
this
.
Inner
.
AddCondition
(
this
.
ToInner
(
condition
));
}
public
bool
Execute
(
CommandFlags
flags
=
CommandFlags
.
None
)
{
return
this
.
Inner
.
Execute
(
flags
);
}
public
Task
<
bool
>
ExecuteAsync
(
CommandFlags
flags
=
CommandFlags
.
None
)
{
return
this
.
Inner
.
ExecuteAsync
(
flags
);
}
public
void
Execute
()
{
this
.
Inner
.
Execute
();
}
}
}
StackExchange.Redis/StackExchange/Redis/KeyspaceIsolation/WrapperBase.cs
0 → 100644
View file @
ae13b6d0
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment