UPDATE 
  cscart_lock_keys 
SET 
  expiry_at = UNIX_TIMESTAMP(NOW()) + 30, 
  token = 'NfkONohME18odx7AAYk03wSIivl6cpx2qBRUei+MSbc=' 
WHERE 
  key_id = '7d0a2a66041be3b9e8725f9240be1553d9d3f736847ed02b05c476027053e10c' 
  AND (
    token = 'NfkONohME18odx7AAYk03wSIivl6cpx2qBRUei+MSbc=' 
    OR expiry_at <= UNIX_TIMESTAMP(NOW())
  )

Query time 0.00033