UPDATE 
  cscart_lock_keys 
SET 
  expiry_at = UNIX_TIMESTAMP(NOW()) + 30, 
  token = 'nNhDkyhcoe25m47bo4q5xMB5bMBac9F1pGugF14YKNk=' 
WHERE 
  key_id = '384015197cabf84feb82c9d0e6c90089349451b658af416e75623afeeb422827' 
  AND (
    token = 'nNhDkyhcoe25m47bo4q5xMB5bMBac9F1pGugF14YKNk=' 
    OR expiry_at <= UNIX_TIMESTAMP(NOW())
  )

Query time 0.00023