0

Here you can read:

64-bit UID's are clever ways to identify a user, but suck when printed out. 18446744073709551616. 20 characters! Using base64 encoding, or even just hexadecimal, you can cut that down by quite a bit Blockquote

but as far I know 18446744073709551616 will result in a bigger string if is encoded using Base64. I know that I´m missing something, cos those memecached people are smart and in the doc they mentioned more than one time that using Base64 encoding could be useul to improve a key before store it into the memcahed. How is that?

2 Answers2

0

Do not threat UID like a string, use rather 64 bit numerical representation. It takes exactly 64 bits or 8 bytes. Encoding 8 bytes using hexadecimal will result in string like "FF1122EE44556677" - 16 bytes. Using base64 encoding you will get even shorter string.

light_keeper
  • 627
  • 5
  • 15
  • Evidently, but the problem here is avoid binary representation of memcached key, so we can use ascii protocol. –  Jun 04 '14 at 13:31
0

What you're looking at is basically the decimal representation of 64 bits. They're probably talking about encoding the underlying bits directly to Base64 or hex, instead of encoding the decimal representation of the bits. They're essentially just talking about alphabet sizes. The larger the alphabet, the shorter the string:

64 bits as bits (alphabet of 2, 0 or 1) is 64 characters
64 bits as decimal (alphabet of 10, 0 - 9) is 20 characters
64 bits as hexadecimal (alphabet of 16, 0 - F) is 16 characters
etc...

deceze
  • 510,633
  • 85
  • 743
  • 889
  • Thanks for your reply. Then what they were talking about was to take the binary representation of the number to feed the input of the [Base64](http://en.wikipedia.org/wiki/Base64) encoding function, getting a shorter string than its decimal representation string? –  Jun 04 '14 at 13:29
  • That's the only thing that makes sense, yes. – deceze Jun 04 '14 at 13:30
  • Thanks again. I ask another question [here](http://stackoverflow.com/questions/24039562/how-to-base64-encode-a-64bit-number-in-php) related to how do this in PHP, cos standard PHP functions don´t seem to fit. –  Jun 04 '14 at 14:04