UPDATE 
  cscart_lock_keys 
SET 
  expiry_at = UNIX_TIMESTAMP(NOW()) + 30, 
  token = 'v7tt94laMN3Y9TQhODWDMX2grSPFcCV3vQnAYGRgZik=' 
WHERE 
  key_id = '78d2bf195821ee180287283eaac8db78d3f0be53e10e141ca1f71e7d3b05b416' 
  AND (
    token = 'v7tt94laMN3Y9TQhODWDMX2grSPFcCV3vQnAYGRgZik=' 
    OR expiry_at <= UNIX_TIMESTAMP(NOW())
  )

Query time 0.00034