UPDATE 
  cscart_lock_keys 
SET 
  expiry_at = UNIX_TIMESTAMP(NOW()) + 30, 
  token = 'Om7aJNoo35PeDWBpqbZ+Ct7CHXHLovp7AiYCv3PO2k0=' 
WHERE 
  key_id = '38b4af15da0e09267820e064b6aceb586f5371b5fa8f320a402b41d567445a16' 
  AND (
    token = 'Om7aJNoo35PeDWBpqbZ+Ct7CHXHLovp7AiYCv3PO2k0=' 
    OR expiry_at <= UNIX_TIMESTAMP(NOW())
  )

Query time 0.00025