<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def hsetnx(self, hashkey, attribute, value):
 """Emulate hsetnx."""


        redis_hash = self._get_hash(hashkey, 'HSETNX', create=True)
        attribute = self._encode(attribute)
        if attribute in redis_hash:
            return long(0)
        else:
            redis_hash[attribute] = self._encode(value)
            return long(1)