Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Get And Touch implementation #151

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

svanellewee
Copy link

@svanellewee svanellewee commented Nov 8, 2018

Good day!
Added Get And Touch Implementation with simple test case.
As per:
https://github.com/memcached/memcached/blob/master/doc/protocol.txt#L348-L384

Questions:

  • Currently my change assumes latest memcache. Must I add some version check/bool config switch to either enable the gat calls or throw NotImplemented when underlying memcache is too old? (Please specify a preference)
  • are the test cases I added sufficient? I also did semi-manual testing using the following:
from __future__ import print_function
from memcache import Client
import random
import time
client = Client(["127.0.0.1:11211"], debug=1, cache_cas=True)
ttl = 1
key = "greeting_{}".format(random.randint(10,1000))
print(client.set(key, "hello", ttl))
print(20 * "-")
reattempts = 10
for i in range(reattempts):
    result = client.gets(key)
    result = result if result is not None else "Nothing!" * 3
    print("GETS: result === {}".format(result))
    time.sleep(0.5)
    for cas_attempt in range(3):
        cas_result = client.cas(key, "hello", ttl)
        if not cas_result:
            break
        print("GETS: cas {}".format(cas_attempt))
key = "greeting_{}".format(random.randint(10,1000))
print(client.set(key, "hello", ttl))
print(20 * "-")
for i in range(reattempts):
    result = client.gats(key, 2)
    result = result if result is not None else "Nothing!" * 3
    print("GATS: result === {}".format(result))
    time.sleep(0.5)
    for cas_attempt in range(3):
        cas_result = client.cas(key, "hello", ttl)
        if not cas_result:
            break

@svanellewee svanellewee force-pushed the gat-addition branch 2 times, most recently from 019196e to 783ea26 Compare November 8, 2018 06:08
@svanellewee
Copy link
Author

Would it be okay for me to update the .travis.yml to use the latest memcached ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant