UPDATE 
  cscart_lock_keys 
SET 
  expiry_at = UNIX_TIMESTAMP(NOW()) + 30, 
  token = 'A0Ge7VbNZCKxtWlcPXm0V+APndbeaUvouQlPHPCfPDM=' 
WHERE 
  key_id = 'f126a809482fb9b6b69a7d8ef38069cd504ae9444c411cac766345288ba03f43' 
  AND (
    token = 'A0Ge7VbNZCKxtWlcPXm0V+APndbeaUvouQlPHPCfPDM=' 
    OR expiry_at <= UNIX_TIMESTAMP(NOW())
  )

Query time 0.00045