API Reference 0.4.0memcached_client

memcached_client library

Properties

final HashAlgorithm CRC_HASH #

final HashAlgorithm CRC_HASH =
   (String key) => (_crc32(encodeUtf8(key)) >> 16) & 0x7fff

final HashAlgorithm FNV1_32_HASH #

final HashAlgorithm FNV1_32_HASH =
   (String key) {
     int len = key.length;
     int rv = FNV_32_INIT;
     for(int code in key.codeUnits) {
       rv *= FNV_32_PRIME;
       rv ^= code;
     }
     return rv & 0xffffffff;
   }

final HashAlgorithm FNV1_64_HASH #

final HashAlgorithm FNV1_64_HASH =
   (String key) {
     int len = key.length;
     int rv = FNV_64_INIT;
     for(int code in key.codeUnits) {
       rv *= FNV_64_PRIME;
       rv ^= code;
     }
     return rv & 0xffffffff;
   }

final HashAlgorithm FNV1A_32_HASH #

final HashAlgorithm FNV1A_32_HASH =
   (String key) {
     int len = key.length;
     int rv = FNV_32_INIT;
     for(int code in key.codeUnits) {
       rv ^= code;
       rv *= FNV_32_PRIME;
     }
     return rv & 0xffffffff;
   }

final HashAlgorithm FNV1A_64_HASH #

final HashAlgorithm FNV1A_64_HASH =
   (String key) {
     int len = key.length;
     int rv = FNV_64_INIT;
     for(int code in key.codeUnits) {
       rv ^= code;
       rv *= FNV_64_PRIME;
     }
     return rv & 0xffffffff;
   }

final int FNV_32_INIT #

final int FNV_32_INIT = 2166136261

final int FNV_32_PRIME #

final int FNV_32_PRIME = 16777619

final int FNV_64_INIT #

final int FNV_64_INIT = 0xcbf29ce484222325

final int FNV_64_PRIME #

final int FNV_64_PRIME = 0x100000001b3

final HashAlgorithm KETAMA_HASH #

final HashAlgorithm KETAMA_HASH =
   (String key) {
     List<int> bkey = computeMd5(key);
     int rv = ((bkey[3] & 0xff) << 24)
         | ((bkey[2] & 0xff) << 16)
         | ((bkey[1] & 0xff) << 8)
         | (bkey[0] & 0xff);
     return rv & 0xffffffff;
   }

Hash md5Digest #

Hash md5Digest = null

final HashAlgorithm NATIVE_HASH #

final HashAlgorithm NATIVE_HASH =
   (String key) => key.hashCode & 0xffffffff

Functions

void setupLogger({String name: '', Level level: Level.ALL}) #

void setupLogger({String name : '', Level level : Level.ALL}) {
 hierarchicalLoggingEnabled = true;
 Logger root = new Logger(name);
 root.level = level;
 root.onRecord.listen((LogRecord r) {
   print('${r.sequenceNumber} ${r.time} ${r.loggerName} ${r.level}: ${r.message}');
 });
}

Logger initStaticLogger(String fullClassName) #

Logger initStaticLogger(String fullClassName) =>
   new Logger(fullClassName);

Logger initLogger(String parent, inst) #

Logger initLogger(String parent, dynamic inst) =>
   new Logger('$parent.${inst.runtimeType}');

bool listEquals(List l1, List l2) #

Returns whether two lists equals to each other per their contents.

bool listEquals(final List l1, final List l2) {
 if (identical(l1, l2)) return true;
 if (l1 == null || l2 == null) return false;
 if (l1.length != l2.length) return false;

 Iterator i1 = l1.iterator;
 Iterator i2 = l2.iterator;

 while(i1.moveNext() && i2.moveNext()) {
   final o1 = i1.current;
   final o2 = i2.current;
   if (!(o1 == null ? o2 == null : o1 == o2))
     return false;
 }
 return true;
}

bool mapEquals(Map m1, Map m2) #

Returns whether two maps equals to each other per their contents.

bool mapEquals(final Map m1, final Map m2) {
 if (identical(m1, m2)) return true;
 if (m1 == null || m2 == null) return false;
 if (m1.length != m2.length) return false;

 for (var k1 in m1.keys) {
   final v1 = m1[k1];
   if (v1 == null) {
     if (!(m2[k1] == null && m2.containsKey(k1)))
       return false;
   } else {
     if (v1 != m2[k1])
       return false;
   }
 }
 return true;
}

int listHashCode(List list) #

Returns hashCode of a List per its contents.

int listHashCode(final List list) {
 if (list == null) return null.hashCode;

 int h = 1;
 for (var e in list) {
   h = 0xffffffff & (31 * h + e.hashCode);
 }
 return h;
}

int mapHashCode(Map map) #

hashCode utility.

Returns hashCode of a Map per its contents.

int mapHashCode(final Map map) {
 if (map == null) return null.hashCode;

 int h = 0;
 for (var key in map.keys)
   h += (key.hashCode ^ map[key].hashCode) & 0xffffffff;
 return h;
}

void copyList(List<int> src, int srci, List<int> dst, int dsti, int len) #

void copyList(List<int> src, int srci, List<int> dst, int dsti, int len) {
 for (int j = 0; j < len; ++j)
   dst[dsti + j] = src[srci + j];
}

int bytesToInt64(List<int> bytes, int start) #

int bytesToInt64(List<int> bytes, int start) =>
   ((bytes[start + 0] & 0xff) << 56) | ((bytes[start + 1] & 0xff) << 48) |
   ((bytes[start + 2] & 0xff) << 40) | ((bytes[start + 3] & 0xff) << 32) |
   ((bytes[start + 4] & 0xff) << 24) | ((bytes[start + 5] & 0xff) << 16) |
   ((bytes[start + 6] & 0xff) << 8)  | (bytes[start + 7] & 0xff);

Uint8List int64ToBytes(int val) #

Uint8List int64ToBytes(int val) {
 if (val >= 9223372036854775808 || val < -9223372036854775808)
   throw new ArgumentError("Integer exceeds 64 bits(-9223372036854775808 ~ 9223372036854775807)");
 final Uint8List bytes = new Uint8List(8);
 bytes[7] = val & 0xff;
 bytes[6] = (val >> 8) & 0xff;
 bytes[5] = (val >> 16) & 0xff;
 bytes[4] = (val >> 24) & 0xff;
 bytes[3] = (val >> 32) & 0xff;
 bytes[2] = (val >> 40) & 0xff;
 bytes[1] = (val >> 48) & 0xff;
 bytes[0] = (val >> 56) & 0xff;
 return bytes;
}

int bytesToInt32HostOrder(List<int> bytes, int start) #

int bytesToInt32HostOrder(List<int> bytes, int start) =>
   ((bytes[start + 3] & 0xff) << 24) | ((bytes[start + 2] & 0xff) << 16) |
   ((bytes[start + 1] & 0xff) << 8)  | (bytes[start + 0] & 0xff);

int bytesToInt32(List<int> bytes, int start) #

int bytesToInt32(List<int> bytes, int start) =>
   ((bytes[start + 0] & 0xff) << 24) | ((bytes[start + 1] & 0xff) << 16) |
   ((bytes[start + 2] & 0xff) << 8)  | (bytes[start + 3] & 0xff);

Uint8List int32ToBytes(int val) #

Uint8List int32ToBytes(int val) {
 if (val >= 2147483648 || val < -2147483648)
   throw new ArgumentError("Integer exceeds 32 bits(-2147483648 ~ 2147483647)");
 final Uint8List bytes = new Uint8List(4);
 bytes[3] = val & 0xff;
 bytes[2] = (val >> 8) & 0xff;
 bytes[1] = (val >> 16) & 0xff;
 bytes[0] = (val >> 24) & 0xff;
 return bytes;
}

int bytesToInt16(List<int> bytes, int start) #

int bytesToInt16(List<int> bytes, int start) =>
   ((bytes[start + 0] & 0xff) << 8) | (bytes[start + 1] & 0xff);

Uint8List int16ToBytes(int val) #

Uint8List int16ToBytes(int val) {
 if (val >= 32768 || val < -32768)
   throw new ArgumentError("Integer exceeds 16 bits(-32768 ~ 32767)");
 final Uint8List bytes = new Uint8List(2);
 bytes[1] = val & 0xff;
 bytes[0] = (val >> 8) & 0xff;
 return bytes;
}

int bytesToInt8(List<int> bytes, int start) #

int bytesToInt8(List<int> bytes, int start) => bytes[start + 0] & 0xff;

Uint8List int8ToBytes(int val) #

Uint8List int8ToBytes(int val) {
 if (val >= 128 || val < -128)
   throw new ArgumentError("Integer exceeds 8 bits(-128 ~ 127)");
 final Uint8List bytes = new Uint8List(1);
 bytes[0] = val & 0xff;
 return bytes;
}

void validateKey(String key, bool binary) #

Key validation

void validateKey(String key, bool binary) {
 List<int> keyBytes = encodeUtf8(key);
 if (keyBytes.length > MemcachedClient.MAX_KEY_LENGTH) {
   throw new ArgumentError("Key is too long (maxlen = "
       "${MemcachedClient.MAX_KEY_LENGTH})");
 }
 if (keyBytes.length == 0) {
   throw new ArgumentError(
       "Key must contain at least one character.");
 }
 if(!binary) {
   // Validate the key
   for (int j = 0; j < key.length; ++j) {
     String b = key[j];
     if (b == ' ' || b == '\n' || b == '\r' || b == 0) {
       throw new ArgumentError(
           "Key contains invalid characters:  ``$key''");
     }
   }
 }
}

HashAlgorithm lookupHashAlgorithm(String name) #

HashAlgorithm lookupHashAlgorithm(String name) {
 if (_algorithmMap == null) {
   _algorithmMap = new HashMap();
   _algorithmMap['NATIVE'] = NATIVE_HASH;
   _algorithmMap['CRC'] = CRC_HASH;
   _algorithmMap['FNV1_64'] = FNV1_64_HASH;
   _algorithmMap['FNV1A_64'] = FNV1A_64_HASH;
   _algorithmMap['FNV1_32'] = FNV1_32_HASH;
   _algorithmMap['FNV1A_32'] = FNV1A_32_HASH;
   _algorithmMap['KETAMA'] = KETAMA_HASH;
 }
 return _algorithmMap[name];
}

List<int> computeMd5(String key) #

List<int> computeMd5(String key) {
 MD5 md5 = new MD5();
 md5.add(encodeUtf8(key));
 return md5.close();
}

Abstract Classes

OP

Classes

Typedefs