UPDATE 
  cscart_lock_keys 
SET 
  expiry_at = UNIX_TIMESTAMP(NOW()) + 30, 
  token = 'ChN1ekvx2axBK8bGCQKht2MToqNs0HxLkekT2YRKKwY=' 
WHERE 
  key_id = '8dfde651d15302361fa18cb64953b9b57079931c7e6ea68ec9c59f807e1742dc' 
  AND (
    token = 'ChN1ekvx2axBK8bGCQKht2MToqNs0HxLkekT2YRKKwY=' 
    OR expiry_at <= UNIX_TIMESTAMP(NOW())
  )

Query time 0.00045