UPDATE 
  q_lock_keys 
SET 
  expiry_at = UNIX_TIMESTAMP(NOW()) + 30, 
  token = '1KzDht2sk0tlNRx6Eh4vQ+GRU0dIN7IijPPQdOdMVjw=' 
WHERE 
  key_id = 'a2c1d7a19ca7f669d51167bd838825956701ab4a1208c3d8c485c05da0504f4a' 
  AND (
    token = '1KzDht2sk0tlNRx6Eh4vQ+GRU0dIN7IijPPQdOdMVjw=' 
    OR expiry_at <= UNIX_TIMESTAMP(NOW())
  )

Query time 0.00031