UPDATE 
  cscart_lock_keys 
SET 
  expiry_at = UNIX_TIMESTAMP(NOW()) + 30, 
  token = 'un+TsrWrPmPJkZP8bDrniZw/O/DkTy+AccfoRsAk904=' 
WHERE 
  key_id = 'f095fd8ff8041285eabb5e996aecadf4599d686090863d259b727e850acc0597' 
  AND (
    token = 'un+TsrWrPmPJkZP8bDrniZw/O/DkTy+AccfoRsAk904=' 
    OR expiry_at <= UNIX_TIMESTAMP(NOW())
  )

Query time 0.00032