UPDATE 
  cscart_lock_keys 
SET 
  expiry_at = UNIX_TIMESTAMP(NOW()) + 30, 
  token = 'TY8PN2QbdW0T+ImBOnDQY3eYaz0He1dUuIqin0ZkE+g=' 
WHERE 
  key_id = '0c761ccefc28361d3a6d708782c70423226bd046958c3824a29ac6979467adab' 
  AND (
    token = 'TY8PN2QbdW0T+ImBOnDQY3eYaz0He1dUuIqin0ZkE+g=' 
    OR expiry_at <= UNIX_TIMESTAMP(NOW())
  )

Query time 0.00043