UPDATE 
  cscart_lock_keys 
SET 
  expiry_at = UNIX_TIMESTAMP(NOW()) + 30, 
  token = '1A9N7CiHypDPnHKdUHMIF3QUz4iwji0KWNbDho719qk=' 
WHERE 
  key_id = 'a7046c54819f80e1416def348e364d87a6a99a831d3a5175790126c5d85a2858' 
  AND (
    token = '1A9N7CiHypDPnHKdUHMIF3QUz4iwji0KWNbDho719qk=' 
    OR expiry_at <= UNIX_TIMESTAMP(NOW())
  )

Query time 0.00066