nodes: 0, module; 1, function_definition; 2, function_name:add; 3, parameters; 4, block; 5, identifier:self; 6, identifier:event; 7, identifier:pk; 8, default_parameter; 9, default_parameter; 10, expression_statement; 11, expression_statement; 12, try_statement; 13, identifier:ts; 14, None; 15, identifier:ttl; 16, None; 17, comment:"""Add an event to event store.
  
          All events were stored in a sorted set in redis with timestamp as
          rank  score.
  
          :param event: the event to be added, format should be ``table_action``
          :param pk: the primary key of event
          :param ts: timestamp of the event, default to redis_server's
           current timestamp
          :param ttl: the expiration time of event since the last update
          :return: bool
          """; 18, assignment; 19, block; 20, except_clause; 21, identifier:key; 22, call; 23, expression_statement; 24, return_statement; 25, as_pattern; 26, comment:# connection error typically happens when redis server can't be; 27, comment:# reached or timed out, the error will be silent with an error; 28, comment:# log and return None.; 29, block; 30, attribute; 31, argument_list; 32, call; 33, True; 34, attribute; 35, as_pattern_target; 36, expression_statement; 37, return_statement; 38, identifier:self; 39, identifier:_keygen; 40, identifier:event; 41, identifier:ts; 42, attribute; 43, argument_list; 44, identifier:redis; 45, identifier:ConnectionError; 46, identifier:e; 47, call; 48, False; 49, identifier:self; 50, identifier:_zadd; 51, identifier:key; 52, identifier:pk; 53, identifier:ts; 54, identifier:ttl; 55, attribute; 56, argument_list; 57, attribute; 58, identifier:error; 59, binary_operator:"redis event store failed with connection error %r" % e; 60, identifier:self; 61, identifier:logger; 62, string:"redis event store failed with connection error %r"; 63, identifier:e
code: def add(self, event, pk, ts=None, ttl=None):
          """Add an event to event store.
  
          All events were stored in a sorted set in redis with timestamp as
          rank  score.
  
          :param event: the event to be added, format should be ``table_action``
          :param pk: the primary key of event
          :param ts: timestamp of the event, default to redis_server's
           current timestamp
          :param ttl: the expiration time of event since the last update
          :return: bool
          """
          key = self._keygen(event, ts)
          try:
              self._zadd(key, pk, ts, ttl)
              return True
          except redis.ConnectionError as e:
              # connection error typically happens when redis server can't be
              # reached or timed out, the error will be silent with an error
              # log and return None.
              self.logger.error(
                  "redis event store failed with connection error %r" % e)
              return False