<commit_before>Upgrading from memcache-client
========

Dalli is not meant to be 100% compatible with memcache-client, there are serveral differences in the API.

Marshalling
---------------

Take this typical operation:

    cache = MemCache.new
    cache.set('abc', 123)

Technically 123 is an Integer and presumably you want `get('abc')` to return an Integer.  Since memcached stores values as binary blobs, Dalli will serialize the value to a binary blob for storage.  When you get() the value back, Ruby will deserialize it properly to an Integer and all will be well.

The memcache-client API allowed you to control marshalling on a per-method basis:

	cache = MemCache.new
    cache.set('abc', 123, 0, true)
    cache.get('abc', true) => '123'
  
    cache.set('abc', 123, 0)
    cache.get('abc') => 123

Note that the last 'raw' parameter is set to true in the first two API calls and so `get` returns a string, not an integer.  In the second example, we don't provide the raw parameter.  Since it defaults to false, it works exactly like Dalli.

Return Values
----------------

In memcache-client, `set(key, value)` normally returns "STORED\r\n".  This is an artifact of the text protocol used in earlier versions of memcached.  Code that checks the return value will need to be updated.  Dalli raises errors for exceptional cases but otherwise returns true or false depending on whether the operation succeeded or not.  These methods are affected:

    set
    add
    replace<commit_msg>Cleanup<commit_after>Upgrading from memcache-client
========

Dalli is not meant to be 100% compatible with memcache-client, there are serveral differences in the API.


Marshalling
---------------

Take this typical operation:

    cache = MemCache.new
    cache.set('abc', 123)

Technically 123 is an Integer and presumably you want `get('abc')` to return an Integer.  Since memcached stores values as binary blobs, Dalli will serialize the value to a binary blob for storage.  When you get() the value back, Ruby will deserialize it properly to an Integer and all will be well.

The memcache-client API allowed you to control marshalling on a per-method basis:

	cache = MemCache.new
    cache.set('abc', 123, 0, true)
    cache.get('abc', true) => '123'
  
    cache.set('abc', 123, 0)
    cache.get('abc') => 123

Note that the last 'raw' parameter is set to true in the first two API calls and so `get` returns a string, not an integer.  In the second example, we don't provide the raw parameter.  Since it defaults to false, it works exactly like Dalli.

If the code is specifying raw as false, you can simply remove that parameter.  If the code is using raw = true, you will need to use the :marshal option to create a Dalli::Client instance that does not perform marshalling:

    Dalli::Client.new(servers, :marshal => false)

If the code is mixing marshal modes, you will need to use two different client instances.


Return Values
----------------

In memcache-client, `set(key, value)` normally returns "STORED\r\n".  This is an artifact of the text protocol used in earlier versions of memcached.  Code that checks the return value will need to be updated.  Dalli raises errors for exceptional cases but otherwise returns true or false depending on whether the operation succeeded or not.  These methods are affected:

    set
    add
    replace
{'fraction_non_alphanumeric': 0.08487194758784991, 'fraction_numerical': 0.0136986301369863, 'mean_word_length': 3.539189189189189, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 8, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6359495', 'n_tokens_mistral': 950, 'n_tokens_neox': 875, 'n_words': 481}