datacoco_redis_tools/redis_tools.py
def fetch_by_key_name(self, key_name, field=None):
        """Retrieve a redis hash_key record by key_name and field if provided.

        Fields are optional. If a field is not provided, all fields are
        returned.

        :param key_name: Redis cache hash_key
        :param field: Optional field
        :return: Result from Redis cache or Log error
        """
        try:
            if field:
                # print('Fetching category: {} for {}'.format(field, key_name))
                response = self.conn.hmget(key_name, field)
                return response[0].decode("utf-8")
            else:
                # print('Fetching all categories for {}'.format(key_name))
                result = self.conn.hgetall(key_name)

            return result
        except Exception as e:
            if field:
                print(
                    "Error fetching category: {} for {}: {}".format(
                        field, key_name, e
                    )
                )
            else:
                print("Error fetching {}: {}".format(key_name, e))
Retrieve a redis hash_key record by key_name and field if provided.

        Fields are optional. If a field is not provided, all fields are
        returned.

        :param key_name: Redis cache hash_key
        :param field: Optional field
        :return: Result from Redis cache or Log error
        
Retrieve a redis hash_key record by key_name and field if provided.
Fields are optional. If a field is not provided, all fields are
returned.
Retrieve a redis hash_key record by key_name and field if provided . Fields are optional . If a field is not provided all fields are returned .
def fetch_by_key_name(self, key_name, field=None):
        try:
            if field:
                response = self.conn.hmget(key_name, field)
                return response[0].decode("utf-8")
            else:
                result = self.conn.hgetall(key_name)
            return result
        except Exception as e:
            if field:
                print(
                    "Error fetching category: {} for {}: {}".format(
                        field, key_name, e
                    )
                )
            else:
                print("Error fetching {}: {}".format(key_name, e))
def fetch_by_key_name ( self , key_name , field = None ) : try : if field : response = self . conn . hmget ( key_name , field ) return response [ 0 ] . decode ( "utf-8" ) else : result = self . conn . hgetall ( key_name ) return result except Exception as e : if field : print ( "Error fetching category: {} for {}: {}" . format ( field , key_name , e ) ) else : print ( "Error fetching {}: {}" . format ( key_name , e ) )
Retrieve a redis hash_key record by key_name and field if provided.
Retrieve a redis hash_key record by key_name and field if provided .
"""Retrieve a redis hash_key record by key_name and field if provided.

        Fields are optional. If a field is not provided, all fields are
        returned.

        :param key_name: Redis cache hash_key
        :param field: Optional field
        :return: Result from Redis cache or Log error
        """ # print('Fetching category: {} for {}'.format(field, key_name)) # print('Fetching all categories for {}'.format(key_name))
Result from Redis cache or Log error
Result from Redis cache or Log error
self
key_name
Redis cache hash_key
Redis cache hash_key
field
None