ReplaceAndTruncateSanitizer

case
class ReplaceAndTruncateSanitizer(replacementChar: String, maxKeyLength: Int) extends MemcachedKeySanitizer

Sanitizer that replaces characters invalid for Memcached and truncates keys if they are over a certain limit.

Convenient because it creates human-readable keys, but only safe for ASCII chars.

Value Params
maxKeyLength

optional, defaults to 250, which is the max length of a Memcached key

replacementChar

optional, defaults to an underscore

trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any

Value members

Concrete methods

def toValidMemcachedKey(key: String): String

Convert the given string to a valid Memcached key by:

Convert the given string to a valid Memcached key by:

  • replacing all invalid characters with underscores
  • truncating the string to 250 characters

From the Memcached protocol spec:

Data stored by memcached is identified with the help of a key. A key is a text string which should uniquely identify the data for clients that are interested in storing and retrieving it. Currently the length limit of a key is set at 250 characters (of course, normally clients wouldn't need to use such long keys); the key must not include control characters or whitespace.

Because of the structure of cache keys, the most useful information is likely to be at the right hand end, so truncation is performed from the left.

Inherited methods

def productElementNames: Iterator[String]
Inherited from
Product
def productIterator: Iterator[Any]
Inherited from
Product

Concrete fields