Last active
February 18, 2016 09:02
-
-
Save watchamcb/8625618560c94eafb3e7 to your computer and use it in GitHub Desktop.
Python function to calculate overhead of Memcached items
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def calc_max_data_len(chunk_size, key_length=0, cas_enabled=True): | |
max_data = chunk_size - (key_length + 1) # less null terminated key | |
max_data -= 48 # item overhead | |
if cas_enabled: | |
max_data -= 8 # bytes for cas | |
max_data -= 2 # data termination \r\n | |
max_data -= len(" 0 %d\r\n" % max_data) # max header with flags 0 | |
return max_data |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment