import logging
import json


def get_value_of_single_value_key(redis_con, key, value_format=None, value_decode=None):
    """
        Purpose:
            Get data from corresponding single-value key passed in (stored
            as strings and will be decoded if necessary).
        Args:
            redis_con (Redis StrictRedis): Connection
                to Redis database
            key (string): key to get data from Redis
            value_format (string): form to return value. Currently
                supports json via json.loads. But can be expanded
            value_decode (string): encoding type for the value
        Return
            value (Object): value stored in the passed
                in key as an object
    """
    logging.info("Getting Data from Redis Database for key: {key}".format(key=key))

    value = redis_con.get(key)
    if value_decode:
        value = value.decode("utf-8")
    if value_format == "json":
        value = json.loads(value)

    return value