Set a key with a timeout value (in seconds).

        :meth:`settimeout` is used to override the shelf's timeout value.

        :param timeout: The timeout value in seconds for the given key.
            ``0`` means that the key will never expire.
        :type timeout: integer

def settimeout(self, key, value, timeout):
        """Set a key with a timeout value (in seconds).

        :meth:`settimeout` is used to override the shelf's timeout value.

        :param timeout: The timeout value in seconds for the given key.
            ``0`` means that the key will never expire.
        :type timeout: integer

        """
        self[key] = value
        if not hasattr(self, '_index'):
            return  # don't update index if __init__ hasn't completed
        self._index[key] = int(time() + timeout) if timeout else None