UPDATE 
  cscart_lock_keys 
SET 
  expiry_at = UNIX_TIMESTAMP(NOW()) + 30, 
  token = 'wN51gDQOAWe8y/MBGGHiB6Fx1RNIwvloxT2NWSKzi4Y=' 
WHERE 
  key_id = '870128041b35b08c76d383c1931714d3cf0c7fd1c974f632c2e1e554fd532a87' 
  AND (
    token = 'wN51gDQOAWe8y/MBGGHiB6Fx1RNIwvloxT2NWSKzi4Y=' 
    OR expiry_at <= UNIX_TIMESTAMP(NOW())
  )

Query time 0.00034