UPDATE 
  cscart_lock_keys 
SET 
  expiry_at = UNIX_TIMESTAMP(NOW()) + 30, 
  token = 'oa4FlSA+UMrrwarqQoiyMcdeY3TPad0ZdaGCRGDmOMs=' 
WHERE 
  key_id = '184b41b3b1377432405ecf90e197c65550b20a5024eb5ba2e3ed5f22e108c318' 
  AND (
    token = 'oa4FlSA+UMrrwarqQoiyMcdeY3TPad0ZdaGCRGDmOMs=' 
    OR expiry_at <= UNIX_TIMESTAMP(NOW())
  )

Query time 0.00046