UPDATE 
  cscart_lock_keys 
SET 
  expiry_at = UNIX_TIMESTAMP(NOW()) + 30, 
  token = 'NhNTEnmcqcuaPeO2on0kPpVKoK2WkffrWUsUwG08X04=' 
WHERE 
  key_id = '31939a0e8724809f2a7048896a418d2598d5c53a133a65b10de48674657ebbe0' 
  AND (
    token = 'NhNTEnmcqcuaPeO2on0kPpVKoK2WkffrWUsUwG08X04=' 
    OR expiry_at <= UNIX_TIMESTAMP(NOW())
  )

Query time 0.00027