UPDATE 
  q_lock_keys 
SET 
  expiry_at = UNIX_TIMESTAMP(NOW()) + 30, 
  token = 'bfaHKkbzJDxgQNjlNSJ1Rc3vNCQhR5c0u30tQoI2Lc8=' 
WHERE 
  key_id = '4d3654e1d8def28bdc29476902a7d7781ac451aeade8c265813538bdc3a513e8' 
  AND (
    token = 'bfaHKkbzJDxgQNjlNSJ1Rc3vNCQhR5c0u30tQoI2Lc8=' 
    OR expiry_at <= UNIX_TIMESTAMP(NOW())
  )

Query time 0.00024