UPDATE 
  cscart_lock_keys 
SET 
  expiry_at = UNIX_TIMESTAMP(NOW()) + 30, 
  token = 'E06SFKiXZbjibhMM93Ik9a9oi9xekATREOu28iPPezo=' 
WHERE 
  key_id = '8b6387f899748141c8998aa5a7cf5554715278f07e8d554357c31a58e7500180' 
  AND (
    token = 'E06SFKiXZbjibhMM93Ik9a9oi9xekATREOu28iPPezo=' 
    OR expiry_at <= UNIX_TIMESTAMP(NOW())
  )

Query time 0.00044