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

Python 3 compatibility changes. #1

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 7 additions & 6 deletions aerospike_cache/cache.py
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ def add(self, key, value, timeout=DEFAULT_TIMEOUT, version=None):

meta = {}
#check if its int or long else use default
if isinstance(timeout, (int , long)):
if isinstance(timeout, int):
meta['ttl'] = timeout
else:
meta['ttl'] = self.timeout
Expand Down Expand Up @@ -303,7 +303,7 @@ def has_key(self, key, version=None):
meta = None
try:
key, meta = self._client.exists(self.make_key(key, version=version))
except Exception, eargs:
except Exception as eargs:
print("error: {0}".format(eargs), file=sys.stderr)

if meta == None:
Expand All @@ -322,7 +322,7 @@ def incr(self, key, delta=1, version=None):
try:
aero_key = self.make_key(key, version=version)
value = self._client.increment(aero_key, self.aero_bin, delta)
except Exception, eargs:
except Exception as eargs:
value = self.get(key) + delta
self.set(key, value)
return value
Expand All @@ -333,18 +333,19 @@ def clear(self):
"""

#remove each record in the bin
def callback((key, meta, bins)):
def callback(key_meta_bins_tuple):
key = key_meta_bins_tuple[0]
self._client.remove(key)

scan_obj = self._client.scan(self.aero_namespace, self.aero_set)

scan_obj.foreach(callback)

def close(self):
def close(self, **kwargs):
"""
closes the database connection
"""
self._client.close()
self._client.close(**kwargs)

def unpickle(self, value):
"""
Expand Down