Permalink
Browse files

Merge pull request #5 from jzablocki/master

Allow full key fidelity
  • Loading branch information...
ingenthr committed Jan 3, 2013
2 parents 047fc91 + 23ebf99 commit 8483ddff80ee7404b4f88c6e9c62db2034f5bc57
@@ -124,6 +124,7 @@
<Compile Include="Memcached\IOperationFactory.cs">
</Compile>
<Compile Include="MemcachedClient.Results.cs" />
+ <Compile Include="Memcached\KeyTransformers\LegacyMemcachedKeyTransformer.cs" />
<Compile Include="Memcached\PerformanceMonitor\DefaultPerformanceMonitorFactory.cs" />
<Compile Include="Memcached\PerformanceMonitor\IPerformanceMonitor.cs" />
<Compile Include="Memcached\PerformanceMonitor\PerformanceCounterInstaller.cs">
@@ -1,47 +1,40 @@
using System;
+using System.Text;
namespace Enyim.Caching.Memcached
{
+ /// <summary>
+ /// A transformer that simply returns the original key.
+ /// A valid UTF-8 key is recommended.
+ /// </summary>
public class DefaultKeyTransformer : KeyTransformerBase
{
- static readonly char[] ForbiddenChars = {
- '\u0000', '\u0001', '\u0002', '\u0003',
- '\u0004', '\u0005', '\u0006', '\u0007',
- '\u0008', '\u0009', '\u000a', '\u000b',
- '\u000c', '\u000d', '\u000e', '\u000f',
- '\u0010', '\u0011', '\u0012', '\u0013',
- '\u0014', '\u0015', '\u0016', '\u0017',
- '\u0018', '\u0019', '\u001a', '\u001b',
- '\u001c', '\u001d', '\u001e', '\u001f',
- '\u0020'
- };
-
public override string Transform(string key)
{
- if (key.IndexOfAny(ForbiddenChars) > -1)
- throw new ArgumentException("Keys cannot contain the chars 0x00-0x20 and space.");
-
+ //default behavior is to allow all valid strings
return key;
}
}
}
#region [ License information ]
/* ************************************************************
- *
- * Copyright (c) 2010 Attila Kiskó, enyim.com
- *
+ *
+ * @author Couchbase <info@couchbase.com>
+ * @copyright 2012 Couchbase, Inc.
+ * Copyright (c) 2010 Attila Kiskó, enyim.com
+ *
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
- *
+ *
* ************************************************************/
#endregion
@@ -0,0 +1,55 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+
+namespace Enyim.Caching.Memcached.KeyTransformers
+{
+ /// <summary>
+ /// A key transfomer that provides support for legacy memcached key rules
+ /// </summary>
+ public class LegacyMemcachedKeyTransformer : KeyTransformerBase
+ {
+ static readonly char[] ForbiddenChars = {
+ '\u0000', '\u0001', '\u0002', '\u0003',
+ '\u0004', '\u0005', '\u0006', '\u0007',
+ '\u0008', '\u0009', '\u000a', '\u000b',
+ '\u000c', '\u000d', '\u000e', '\u000f',
+ '\u0010', '\u0011', '\u0012', '\u0013',
+ '\u0014', '\u0015', '\u0016', '\u0017',
+ '\u0018', '\u0019', '\u001a', '\u001b',
+ '\u001c', '\u001d', '\u001e', '\u001f',
+ '\u0020'
+ };
+
+ public override string Transform(string key)
+ {
+ if (key.IndexOfAny(ForbiddenChars) > -1)
+ throw new ArgumentException("Keys cannot contain the chars 0x00-0x20 and space.");
+
+ return key;
+ }
+ }
+}
+
+#region [ License information ]
+/* ************************************************************
+ *
+ * @author Couchbase <info@couchbase.com>
+ * @copyright 2012 Couchbase, Inc.
+ * Copyright (c) 2010 Attila Kiskó, enyim.com
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * ************************************************************/
+#endregion

0 comments on commit 8483ddf

Please sign in to comment.