UPDATE 
  cscart_lock_keys 
SET 
  expiry_at = UNIX_TIMESTAMP(NOW()) + 30, 
  token = 'p9EFlAYbVz5S6NBd0ciQHKkyMV8p7mmK+Q2fRwaounI=' 
WHERE 
  key_id = '9b7a8ad89c53069248dcfd1c083ca84143e746552689b8fa089dac110d520349' 
  AND (
    token = 'p9EFlAYbVz5S6NBd0ciQHKkyMV8p7mmK+Q2fRwaounI=' 
    OR expiry_at <= UNIX_TIMESTAMP(NOW())
  )

Query time 0.00061