Example #1
0
	def registerUser(self,email,username):
		"""
		Register a user.
		"""
		if(not self.memc): return
		cacheku = util.sanitize_cache_key(username)
		cacheke = util.sanitize_cache_key(email)
		self.memc.set(("user(%s).email" % (cacheke)),True)
		self.memc.set(("user(%s).username" % (cacheku)),True)
		self.setUsernameStatus(username,EXISTS)
		self.setEmailStatus(email,EXISTS)
		self.setTotalTagsForUsername(username,0)
Example #2
0
	def unregisterUser(self,email,username):
		"""
		Unregister a user
		"""
		if(not self.memc): return
		cacheku = util.sanitize_cache_key(username)
		cacheke = util.sanitize_cache_key(email)
		self.memc.delete("user(%s).email" % (cacheke))
		self.memc.delete("user(%s).username" % (cacheku))
		self.setUsernameStatus(username,NOT_EXISTS)
		self.setEmailStatus(email,NOT_EXISTS)
		self.clearTotalTagsForUsername(username)
		self.clearUserInfoForUsername(username)
Example #3
0
	def setUsernameStatus(self,username,status):
		"""
		Set the username status.
		"""
		if(not self.memc): return
		cachek = util.sanitize_cache_key(username)
		self.memc.set("user(%s).username" % (cachek), status)
Example #4
0
	def setTotalTagsForUsername(self,username,val):
		"""
		Set the total tag count for a username.
		"""
		if(not self.memc): return
		cachek = util.sanitize_cache_key(username)
		self.memc.set("user(%s).totalTags" % (cachek),val)
Example #5
0
	def userIdForUsername(self,username):
		"""
		Get a userId for a username.
		"""
		if(not self.memc): return -1
		cachek = util.sanitize_cache_key(username)
		return self.memc.get("user(%s).userId" % (cachek))
Example #6
0
	def clearUserInfoForUsername(self,username):
		"""
		Clear cached user info for a username.
		"""
		if(not self.memc): return
		cachek = util.sanitize_cache_key(username)
		self.memc.delete("user(%s).info" % (cachek))
Example #7
0
	def setUserIdForUsername(self,username,userId):
		"""
		Set a user id for their username.
		"""
		if(not self.memc): return
		cachek = util.sanitize_cache_key(username)
		self.memc.set("user(%s).userId" % (cachek), userId)
Example #8
0
	def setUserInfoForUsername(self,username,info):
		"""
		Set user info for a username.
		"""
		if(not self.memc): return
		cachek = util.sanitize_cache_key(username)
		self.memc.set("user(%s).info" % (cachek), info)
Example #9
0
	def clearTotalTagsForUsername(self,username):
		"""
		Delete the total tags count for a username.
		"""
		if(not self.memc): return
		cachek = util.sanitize_cache_key(username)
		self.memc.delete("user(%s).totalTags" % (cachek))
Example #10
0
	def setAuthentication(self,username,password):
		"""
		Set authentication in cache.
		"""
		if(not self.memc): return
		cachek = util.sanitize_cache_key(username)
		self.memc.set("user(%s).auth" % (cachek),password)
Example #11
0
	def doesEmailExist(self,email):
		"""
		Check whether or not an email exists.
		"""
		if(not self.memc): return 0
		cachek = util.sanitize_cache_key(email)
		return self.memc.get("user(%s).email" % (cachek))
Example #12
0
	def setEmailStatus(self,email,status):
		"""
		Set the email status.
		"""
		if(not self.memc): return
		cachek = util.sanitize_cache_key(email)
		self.memc.set("user(%s).email" % (cachek), status)
Example #13
0
	def incrementTotalTagsForUsername(self,username):
		"""
		Increment the total tags for a username.
		"""
		if(not self.memc): return
		cachek = util.sanitize_cache_key(username)
		self.memc.incr("user(%s).totalTags" % (cachek))
		self.clearUserInfoForUsername(username)
Example #14
0
	def getUserInfoForUsername(self,username):
		"""
		Get user info for a username.
		"""
		if(not self.memc): return
		cachek = util.sanitize_cache_key(username)
		res = self.memc.get("user(%s).info" % (cachek))
		return 
Example #15
0
	def totalTagsForUsername(self,username):
		"""
		Get the total tag cound for a username.
		"""
		if(not self.memc): return -1
		cachek = util.sanitize_cache_key(username)
		res = self.memc.get("user(%s).totalTags" % (cachek))
		if(not res): return -1
		return res
Example #16
0
	def doesUsernameExist(self,username):
		"""
		Check whether or not a username exists.
		"""
		if(not self.memc): return 0
		cachek = util.sanitize_cache_key(username)
		res = self.memc.get("user(%s).username" % (cachek))
		if(not res): return NO_KEY
		return res
Example #17
0
	def authenticate(self,username,password):
		"""
		Check authencitation from cache.
		"""
		if(not self.memc): return False
		cachek = util.sanitize_cache_key(username)
		passwd = self.memc.get("user(%s).auth" % (cachek))
		if(not passwd): return False
		if(passwd == password): return True
		self.memc.delete("user(%s).auth" % (cachek))